QuickBEAM.Cover (QuickBEAM v0.10.6)

Copy Markdown View Source

JavaScript coverage tool for mix test --cover.

Reports line-level coverage for all JS/TS code executed through QuickBEAM runtimes during the test suite, alongside standard Elixir coverage.

Setup

# mix.exs
def project do
  [
    ...,
    test_coverage: [tool: QuickBEAM.Cover]
  ]
end

Then run:

$ mix test --cover

Elixir coverage works as normal (delegates to Erlang's :cover). JS coverage is collected automatically from all QuickBEAM runtimes that start during the test run.

Options

Accepts all standard :test_coverage options, plus:

  • :js — keyword list of JS-specific options:
    • :ignore — file patterns to exclude (default: ["node_modules/**"])

Using with excoveralls

If you already use excoveralls, add JS coverage as a sidecar:

# test/test_helper.exs
QuickBEAM.Cover.start()
ExUnit.after_suite(fn _ -> QuickBEAM.Cover.stop() end)

JS coverage is written to cover/js_lcov.info.

Summary

Functions

Record JS coverage data collected from a runtime.

Mix test coverage callback. Called by ExUnit when test_coverage: [tool: QuickBEAM.Cover] is set.

Functions

enabled?()

@spec enabled?() :: boolean()

export_istanbul(path, data)

@spec export_istanbul(Path.t(), map()) :: :ok

export_lcov(path, data)

@spec export_lcov(Path.t(), map()) :: :ok

record(coverage_map)

@spec record(map()) :: :ok

Record JS coverage data collected from a runtime.

results(opts \\ [])

@spec results(keyword()) :: map()

start()

@spec start() :: :ok

start(compile_path, opts)

Mix test coverage callback. Called by ExUnit when test_coverage: [tool: QuickBEAM.Cover] is set.

stop(opts \\ [])

@spec stop(keyword()) :: map()