Skip to content

A formatter for ExUnit that emits JSON objects. Designed to be compatible with mocha-json-streamier-reporter

License

Notifications You must be signed in to change notification settings

johns10/exunit_json_formatter

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ExUnitJsonFormatter

An ExUnit formatter that outputs a series of JSON objects.

Inspired and designed to be compatible with mocha-json-streamier-reporter

Installation

If available in Hex, the package can be installed by adding exunit_json_formatter to your list of dependencies in mix.exs:

def deps do
  [{:exunit_json_formatter, "~> 0.1.0"}]
end

Usage

Output to stdout (default)

Configure the formatter in test/test_helper.exs:

ExUnit.start(formatters: [ExUnitJsonFormatter])

Output to file

There are multiple ways to configure file output:

1. Via test_helper.exs (recommended)

ExUnit.start(formatters: [{ExUnitJsonFormatter, output_file: "test-results.json"}])

2. Via environment variable

EXUNIT_JSON_OUTPUT_FILE=test-results.json mix test --formatter ExUnitJsonFormatter

or

export EXUNIT_JSON_OUTPUT_FILE=test-results.json
mix test --formatter ExUnitJsonFormatter

3. Via mix.exs configuration

def project do
  [
    # ...
    test_coverage: [
      tool: ExUnitJsonFormatter,
      output_file: "test-results.json"
    ]
  ]
end

Note: Options specified in test_helper.exs take precedence over environment variables.

File output is useful when you need clean JSON output separate from test logs and other CLI output.

Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/exunit_json_formatter.

About

A formatter for ExUnit that emits JSON objects. Designed to be compatible with mocha-json-streamier-reporter

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Elixir 100.0%