-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Fix issue with using 'chalk' in tests #1244
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Seems like |
Hi @jhnns. The code path where That said we closed #1124 because it seemed fixed. Are you still running into this issue with the latest AVA version? |
That is true, but since some of the required dependencies might also require chalk or supports-color (you never know 😉), I thought it would be better to re-arrange all require statements. But I can change that if you're not ok with that.
My test is failing if my patch is not applied, so I assume that the issue is still there. |
Could you share your test? Where / how specifically is it failing? I don't fully understand this color support stuff. I'd wait for @sindresorhus to chime in before updating this PR. |
It's included in the PR. If the patch is not applied, the test fails saying that In order to finish this PR from my perspective I would need to fix it on Travis. But it's hard to debug it since it works locally ^^ |
It's not enough with just |
AVA 0.18.2: import chalk from 'chalk';
import test from 'ava';
test(t => {
t.true(chalk.enabled);
});
Seems to already work fine? |
test/fixture/chalk.js
Outdated
import test from '../../'; | ||
|
||
test('should support colors', t => { | ||
t.is(chalk.enabled, true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
t.true(chalk.enabled);
385f2cd
to
fe9362e
Compare
Yes, I can confirm that. Since I've update my PR and just added tests to While skimming the source code, I saw that in So from my POV, you should decide whether you want to:
The current PR reflects the second choice, but I'm willing to change that since I've already invested some time in it. Just tell me what you want. If you don't care about this and you want me to leave you alone, that's also fine. Then just close this 😁 |
fe9362e
to
6275552
Compare
6275552
to
46c1d1f
Compare
Sorry about the super slow reply. I agree with the second option, good choice. Thank you for looking into this and your extensive detective work :) |
I just love ava as a test runner 👍 |
This PR fixes a bug where the chalk module reported that the current terminal does not support colors.
'chalk' is using the 'supports-color' module which reads process.stdout.isTTY as soon as it is required. Since our process-adapter is initializing a fake TTY support, we must ensure that 'supports-color' is not executed before our fake TTY support is initialized.
I just re-arranged the
require()
statements. Also added tests for it.Fixes #1124