Skip to content

Latest commit

 

History

History
63 lines (42 loc) · 1.1 KB

File metadata and controls

63 lines (42 loc) · 1.1 KB

minitest-json-reporter

A Minitest reporter plugin that emits test results as JSON.

Installation

Add the gem to your application's Gemfile:

group :test do
  gem "minitest-json-reporter"
end

Then install:

bundle install

Usage

Load the plugin from your test helper:

require "minitest/json_reporter"

You can then enable JSON output with the existing CLI flag:

rails test --json
ruby -Ilib:test test/example_test.rb --json

For runners that need to work with Rails 8, prefer the environment variable. Rails 8 loads test files after Minitest starts parsing CLI options, so custom flags loaded from test_helper.rb are too late, but environment-based activation works:

MINITEST_JSON=1 rails test
MINITEST_JSON=1 ruby -Ilib:test test/example_test.rb

You can also enable the reporter from Ruby:

require "minitest/json_reporter"

Minitest::JsonReporter.use!

Development

Run tests with:

bundle exec rake test

License

The gem is available as open source under the terms of the MIT License.