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
[Bug]: failureMessage is coloured when syntax errors #14998
Comments
Did you try: npx jest --json --no-color or:
For me these work as expected, i.e. there no no ansi escape codes in the output. Although I don’t see |
I see it regularly. My test files are in typescript and I use ts-jest // hello.test.ts
test('sum', () => { expec(1+2).toEqual(3) }) $$ // jest.config.ts
import type {Config} from 'jest';
const config: Config = { preset: 'ts-jest' };
export default config;
{"numFailedTestSuites":1,"numFailedTests":0,"numPassedTestSuites":0,"numPassedTests":0,"numPendingTestSuites":0,"numPendingTests":0,"numRuntimeErrorTestSuites":1,"numTodoTests":0,"numTotalTestSuites":1,"numTotalTests":0,"openHandles":[],"snapshot":{"added":0,"didUpdate":false,"failure":false,"filesAdded":0,"filesRemoved":0,"filesRemovedList":[],"filesUnmatched":0,"filesUpdated":0,"matched":0,"total":0,"unchecked":0,"uncheckedKeysByFile":[],"unmatched":0,"updated":0},"startTime":1712138134523,"success":false,"testResults":[{"assertionResults":[],"coverage":{},"endTime":1712138135196,"message":" ● Test suite failed to run\n\n \u001b[96mhello.test.ts\u001b[0m:\u001b[93m1\u001b[0m:\u001b[93m21\u001b[0m - \u001b[91merror\u001b[0m\u001b[90m TS2552: \u001b[0mCannot find name 'expec'. Did you mean 'expect'?\n\n \u001b[7m1\u001b[0m test('sum', () => { expec(1+2).toEqual(3) })\n \u001b[7m \u001b[0m \u001b[91m ~~~~~\u001b[0m\n\n \u001b[96mnode_modules/@types/jest/index.d.ts\u001b[0m:\u001b[93m14\u001b[0m:\u001b[93m15\u001b[0m\n \u001b[7m14\u001b[0m declare const expect: jest.Expect;\n \u001b[7m \u001b[0m \u001b[96m ~~~~~~\u001b[0m\n 'expect' is declared here.\n \u001b[96mhello.test.ts\u001b[0m:\u001b[93m2\u001b[0m:\u001b[93m1\u001b[0m - \u001b[91merror\u001b[0m\u001b[90m TS2304: \u001b[0mCannot find name '$$'.\n\n \u001b[7m2\u001b[0m $$\n \u001b[7m \u001b[0m \u001b[91m~~\u001b[0m\n","name":"/home/path/to/hello.test.ts","startTime":1712138135196,"status":"failed","summary":""}],"wasInterrupted":false} |
As already mentioned, |
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days. |
Version
29.7.0
Steps to reproduce
test('sum', () => { expec(1+2).toEqual(3) }); $$
jest --json
orjest | cat
Expected behavior
I expect
failureMessage
ortestExecError
to not have colour codesActual behavior
failureMessage
andtestExecError
has colour codesAdditional context
This isn't about writing to stdout, as these properties will have colours in them if you're writing custom reporters as well.
I haven't dug who introduces those codes, but
--colors
orFORCE_COLORS
config does not impact them.Environment
The text was updated successfully, but these errors were encountered: