Skip to content

[CI=true] toMatchFileSnapshot always mismatched if empty file #5891

@gterras

Description

@gterras

Describe the bug

Following #5890:

toMatchFileSnapshot(EMPTY_FILE) will consistently fail when CI=true.

As pointed out by @hi-ogawa:

Vitest probably got confused by empty snapshot file and tries to create a new snapshot, but that's not allowed on CI environment (i.e. it's treated as error by default).

Reproduction

https://github.com/gterras/repro-vitest-snapshot

  • npm run test => OK
  • npm run test:ci => KO

System Info

  Binaries:
    Node: 20.12.2 - ~/.nvm/versions/node/v20.12.2/bin/node
    npm: 10.5.0 - ~/.nvm/versions/node/v20.12.2/bin/npm
  npmPackages:
    vitest: ^1.6.0 => 1.6.0

Used Package Manager

npm

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    p3-minor-bugAn edge case that only affects very specific usage (priority)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions