jest icon indicating copy to clipboard operation
jest copied to clipboard

[Bug]: Snapshot fails when test title contains `\r`(Carriage Return, CR)

Open fisker opened this issue 6 months ago • 0 comments

Version

30.0.0

Steps to reproduce

  1. Clone https://github.com/fisker/vitest-snapshot-test-bug-line-break-in-title
  2. Run yarn
  3. Run yarn jest
  4. You should see
>yarn jest
yarn run v1.22.19
$ node --experimental-vm-modules node_modules/jest/bin/jest.js jest.test.js
(node:18968) ExperimentalWarning: VM Modules is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
 PASS  ./jest.test.js
 (4 ms)
  √ CRLF
 (1 ms)

 › 2 snapshots written.
 › 2 snapshots obsolete.
   • CR
 1
   • CRLF
 1
Snapshot Summary
 › 2 snapshots written from 1 test suite.
 › 2 snapshots obsolete from 1 test suite. To remove them all, run `yarn run jest -u`.
   ↳ ./jest.test.js
       • CR
 1
       • CRLF
 1

Test Suites: 1 passed, 1 total
Tests:       2 passed, 2 total
Snapshots:   2 obsolete, 2 written, 2 total
Time:        0.371 s, estimated 1 s
Ran all test suites matching jest.test.js.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Expected behavior

Test should pass.

Actual behavior

It fails.

Additional context

Previously reported in https://github.com/jestjs/jest/issues/15203 https://github.com/jestjs/jest/issues/15204 https://github.com/jestjs/jest/issues/2969

Environment

System:
    OS: Windows 10 10.0.19045
    CPU: (8) x64 Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
  Binaries:
    Node: 22.14.0 - ~\AppData\Local\fnm_multishells\29504_1749672877022\node.EXE
    Yarn: 1.22.19 - D:\npm\yarn.CMD
    npm: 9.1.2 - ~\AppData\Local\fnm_multishells\29504_1749672877022\npm.CMD
    pnpm: 10.4.1 - D:\npm\pnpm.CMD
    bun: 1.2.15 - ~\.bun\bin\bun.EXE
  npmPackages:
    jest: ^30.0.0 => 30.0.0

fisker avatar Jun 11 '25 20:06 fisker