Demonstrate crash when using Truecolor methods and color is unsupported (#174)

This commit is contained in:
Vadim Demedes 2017-07-22 01:03:49 +03:00 committed by Sindre Sorhus
parent 23092eefd2
commit 5cdd9eddf8
3 changed files with 13 additions and 0 deletions

View file

@ -2,6 +2,7 @@
const assert = require('assert');
const importFresh = require('import-fresh');
const resolveFrom = require('resolve-from');
const execa = require('execa');
// Spoof supports-color
require.cache[resolveFrom(__dirname, 'supports-color')] = {
@ -202,6 +203,13 @@ describe('chalk.level', () => {
assert.equal(chalk.level, 1);
chalk.level = oldLevel;
});
it('should disable colors if they are not supported', () => {
return execa('node', ['fixture'])
.then(result => {
assert.equal(result.stdout, 'test');
});
});
});
describe('chalk.enabled', () => {