You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The tty.isatty(fd) method returns true when executed with Mocha. And it returns false with Stryker. I have this problem with Chalk (a library for adding color to the terminal) which doesn't colorize the text when my tests are run with Stryker. I've also reproduced the problem with picocolors.
The tty.isatty() method returns true if the given fd is associated with a TTY and false if it is not, including whenever fd is not a non-negative integer.
1:44:39 (57824) WARN ProjectReader Warning: No files found for mutation with the given glob expressions. As a result, a dry-run will be performed without actually modifying anything. If you intended to mutate files, please check and adjust the configuration. Current glob pattern(s) used: "{src,lib}/**/!(*.+(s|S)pec|*.+(t|T)est).+(cjs|mjs|js|ts|jsx|tsx|html|vue)", "!{src,lib}/**/__tests__/**/*.+(cjs|mjs|js|ts|jsx|tsx|html|vue)". To enable file mutation, consider configuring the `mutate` property in your configuration file or using the --mutate option via the command line.
11:44:39 (57824) INFO Instrumenter Instrumented 0 source file(s) with 0 mutant(s)
11:44:39 (57824) INFO ConcurrencyTokenProvider Creating 7 test runner process(es).
11:44:40 (57824) INFO DryRunExecutor Starting initial test run (mocha test runner with "perTest" coverage analysis). This may take a while.
11:44:40 (57824) ERROR DryRunExecutor One or more tests failed in the initial test run:
tty isatty
false == true
11:44:40 (57824) ERROR Stryker There were failed tests in the initial test run.
Hmm, interesting. Indeed, Stryker runs your tests outside of a tty because it runs your test in a child process. You can mimic the same behavior with this script:
On reflection, it's not good practice to write a test that depends on an external element. For example, redirecting the output to a file (npx mocha > report.log): the tests no longer work.
And my tests only check the case where Chalk puts color in the text. Perhaps without color, my program fails.
For my tests, I'm going to run a test with the color forced and another without.
importassertfrom"node:assert/strict";importprocessfrom"node:process";importmyAwesomeProgramfrom"../src/my_awesome_program";describe("myAwesomeProgram",function(){afterEach(function(){deleteprocess.env.FORCE_COLOR;});it("support color",function(){process.env.FORCE_COLOR="1";constresult=myAwesomeProgram("foo");assert.equal(result,"bar");});it("support no color",function(){process.env.FORCE_COLOR="0";constresult=myAwesomeProgram("foo");assert.equal(result,"baz");});});
It's still a shame that the tests behave differently between Mocha and Stryker. But the problem raised in this issue seems to come from bad tests in my project. Personally, I no longer need this difference fixed. You can close this issue if you want.
Summary
The
tty.isatty(fd)
method returnstrue
when executed with Mocha. And it returnsfalse
with Stryker. I have this problem with Chalk (a library for adding color to the terminal) which doesn't colorize the text when my tests are run with Stryker. I've also reproduced the problem with picocolors.package.json
stryker.config.js
test/index.js
Test runner environment
npm install
npx mocha
npx stryker run
Your Environment
Add stryker.log
The text was updated successfully, but these errors were encountered: