Skip to content
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

Switch back to Hoek.clone from lodash.deepClone. #898

Merged
merged 10 commits into from Dec 17, 2018
Prev

Explicitly test for color output on supporting consoles.

Coverage should not be dependent on the build environment's console, and Travis CI seems to set process.stdout.isTTY to false on its Windows environment.
  • Loading branch information
Invader444 committed Dec 16, 2018
commit a9c6b7a691c0e2e426e257119e18e77501416ccb
@@ -38,9 +38,9 @@
"lab": "./bin/lab"
},
"scripts": {
"test": "node ./bin/_lab -fL -t 100 -m 3000",
"test": "node ./bin/_lab -fL -t 100 -m 10000",
"posttest": "npm run lint-md",
"test-cov-html": "node ./bin/_lab -fL -r html -m 3000 -o coverage.html",
"test-cov-html": "node ./bin/_lab -fL -r html -m 10000 -o coverage.html",
"lint": "node ./bin/_lab -d -f -L",
"lint-md": "eslint --config hapi --rule \"strict: 0, eol-last: 0\" --plugin markdown --ext md --parser-options \"ecmaVersion: 9\" ."
},
@@ -999,6 +999,39 @@ describe('Reporter', () => {
expect(output).to.match(/^\n \n \.\n\n1 tests complete\nTest duration: \d+ ms\nNo global variable leaks detected\n\n$/);
});

it('includes colors when terminal supports', async () => {

delete require.cache[require.resolve('supports-color')];
const orig = {
isTTY: process.stdout.isTTY,
env: process.env
};
process.stdout.isTTY = true;
process.env = {
FORCE_COLOR: true
};

const script = Lab.script();
script.experiment('test', () => {

script.test('works', () => {

expect(true).to.equal(true);
});
script.test('does not work', () => {

expect(true).to.equal(false);
});
});

const { code, output } = await Lab.report(script, { reporter: 'console', output: false, assert: false });

process.stdout.isTTY = orig.isTTY;
process.env = orig.env;
expect(code).to.equal(1);
expect(output).to.match(/^\n \n \.\u001b\[31mx\u001b\[0m\n\nFailed tests:\n\n 2\) test does not work:\n\n \u001b\[37;41mactual\u001b\[0m \u001b\[30;42mexpected\u001b\[0m\n\n \u001b\[37;41mtrue\u001b\[0m\u001b\[30;42mfalse\u001b\[0m\n\n \u001b\[33mExpected true to equal specified value: false\u001b\[0m\n\n.*?\u001b\[0m\n\n\n\u001b\[31m1 of 2 tests failed\u001b\[0m\nTest duration: \d+ ms\n\u001b\[32mNo global variable leaks detected\u001b\[0m\n\n$/);
});

it('displays custom error messages in expect', async () => {

const script = Lab.script();
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.