Skip to content

Initial test run of Jest source code in VS Code on Windows fails due to snapshots missing color tags #7486

Closed
@urig

Description

🐛 Bug Report

When Jest performs its initial test run in VS Code on Windows, a large number of snapshot tests fail because the Received snapshot is missing color tags (ex: <red>)

To Reproduce

  1. In Windows 10, follow the steps in the Contributing Guide
  2. Open Jest in VS Code (v1.29.1)
  3. Switch to the Output window to view test results as the run progresses.

Actual behavior

A large number of snapshot tests FAIL. From a cursory glance, the cause of the failure is the lack of color tags in the Received snapshots. For example:

FAIL packages/jest-config/src/__tests__/normalize.test.js (10.679s)

  ● rootDir › throws if the options is missing a rootDir property

    expect(value).toMatchSnapshot()

    Received value does not match stored snapshot "rootDir throws if the options is missing a rootDir property 1".

    - Snapshot
    + Received

    - "<red><bold><bold>● <bold>Validation Error</>:</>
    - <red></>
    - <red>  Configuration option <bold>rootDir</> must be specified.</>
    - <red></>
    - <red>  <bold>Configuration Documentation:</></>
    - <red>  https://jestjs.io/docs/configuration.html</>
    - <red></>"
    + "● Validation Error:
    + 
    +   Configuration option rootDir must be specified.
    + 
    +   Configuration Documentation:
    +   https://jestjs.io/docs/configuration.html
    + "

      at Object.toThrowErrorMatchingSnapshot (packages/jest-config/src/__tests__/normalize.test.js:96:8)

Expected behavior

Snapshot tests are expected to PASS.

Link to repl or repo (highly encouraged)

https://github.com/urig/jest/

Run npx envinfo --preset jest

Paste the results here:

  System:
    OS: Windows 10
    CPU: x64 Intel(R) Core(TM) i7-5500U CPU @ 2.40GHz
  Binaries:
    Yarn: 1.12.3 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
    npm: 6.4.1 - C:\Program Files\nodejs\npm.CMD

Notes

Note: I think the lack of color tags in the Received snapshots is not surprising given that the command used to run the tests is shown to include the --no-color switch:

$ node ./packages/jest-cli/bin/jest.js --json --useStderr --outputFile C:\Users\urig\AppData\Local\Temp/jest_runner.json --no-color

The question is - Why does the command include this switch?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions