Skip to content

Commit

Permalink
test: unexpected-error test expects non-colored output
Browse files Browse the repository at this point in the history
The assertions in unexpected-error.spec.ts expect the output being tested to not contain ANSI color codes. To ensure that is always the case, set FORCE_COLOR="0" so node doesn't output colors.

Without this change, this test will pass or fail depending upon the terminal being used to run the tests. With this change, the test runs consistently.
  • Loading branch information
candrews authored and thisislawatts committed Sep 4, 2024
1 parent 04a0592 commit dcfbeec
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions test/jest/unit/lib/unexpected-error.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as path from 'path';
import { runCommand } from '../../util/runCommand';
import { RunCommandOptions, runCommand } from '../../util/runCommand';
import { getFixturePath } from '../../util/getFixturePath';

/**
Expand All @@ -15,7 +15,13 @@ import { getFixturePath } from '../../util/getFixturePath';
describe('callHandlingUnexpectedErrors', () => {
async function runScript(filename: string) {
const file = path.resolve(getFixturePath('unexpected-error'), filename);
return runCommand('node', ['-r', 'ts-node/register', file]);
const options: RunCommandOptions = {
env: {
FORCE_COLOR: '0',
PATH: process.env.PATH,
},
};
return runCommand('node', ['-r', 'ts-node/register', file], options);
}

it('calls the provided callable', async () => {
Expand Down

0 comments on commit dcfbeec

Please sign in to comment.