Closed
Description
What is the problem this feature will solve?
#45712 added support for custom test reporters, which is great!
It’s still a but cumbersome having to specify the --test-reporter
flag for every test run.
What is the feature you are proposing to solve the problem?
Use an environment variable NODE_TEST_REPORTER
. If this is set, this will override the default tap
runner. The command line argument will still take precedence. If this is specified, it will entirely ignore the NODE_TEST_REPORTER
environment variable.
# Uses the tap formatter
node --test
# Uses the spec formatter
NODE_TEST_REPORTER=spec node --test
# Uses the tap formatter
NODE_TEST_REPORTER=spec node --test --test-reporter tap
This allows users to define their preferred formatter in their environment, e.g. in ~/.bashrc
or ~/.zshrc
What alternatives have you considered?
It could also be supported in NODE_OPTIONS
. However, people use this for different purposes too.