Skip to content

Commit

Permalink
Use more robust and isolated approach to manipulating color level
Browse files Browse the repository at this point in the history
  • Loading branch information
gcorne committed May 7, 2021
1 parent 2d91c6e commit d86efc7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
3 changes: 0 additions & 3 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// Chalk can cause snapshots to with its styling, just disable the color instead
process.env.FORCE_COLOR = 0;

module.exports = {
testEnvironment: 'node',
projects: ['<rootDir>/packages/*'],
Expand Down
2 changes: 1 addition & 1 deletion packages/cli-lib/__tests__/__snapshots__/schema.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ Array [

exports[`cli-lib/schema logSchemas() logs schemas 1`] = `
"╔════════╤════════╤══════════════╗
[1mLabel[22m[1mName[22m[1mobjectTypeId[22m
LabelNameobjectTypeId
║ Schema │ schema │ 2-123 ║
╚════════╧════════╧══════════════╝
"
Expand Down
8 changes: 8 additions & 0 deletions packages/cli-lib/__tests__/schema.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const fs = require('fs-extra');
const path = require('path');
const chalk = require('chalk');
const { cleanSchema, writeSchemaToDisk, logSchemas } = require('../schema');
const { logger } = require('../logger');
const { getCwd } = require('../path');
Expand All @@ -8,6 +9,13 @@ const full = require('./fixtures/schema/full.json');
const multiple = require('./fixtures/schema/multiple.json');

describe('cli-lib/schema', () => {
const originalChalkLevel = chalk.level;
beforeEach(() => {
chalk.level = 0;
});
afterEach(() => {
chalk.level = originalChalkLevel;
});
describe('cleanSchema()', () => {
it('cleans a basic schema', () => {
expect(cleanSchema(basic)).toMatchSnapshot();
Expand Down

0 comments on commit d86efc7

Please sign in to comment.