Skip to content
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]: snapshot update does not remove .snap files if file is renamed or stops producing snapshots #142

Open
Aghassi opened this issue Jun 29, 2023 · 0 comments
Labels
bug Something isn't working untriaged Requires traige

Comments

@Aghassi
Copy link

Aghassi commented Jun 29, 2023

What happened?

There is a bug today where doing bazel run will pass, but not remove the stale snapshot. If you run bazel test, the snapshot will be marked as stale. To keep parity with jest, I would expect bazel run to clean out the the source tree when a file is missing. Generated files test can do this today, so I would expect after a snapshot run to use a generated files test like write_source_files to remove deleted files.

Version

Development (host) and target OS/architectures:

Output of bazel --version: 6.2.0

Version of the Aspect rules, or other relevant rules from your
WORKSPACE or MODULE.bazel file:
0.19 - rules_jest

Language(s) and/or frameworks involved:

How to reproduce

`bazel run` a test target that produces a snapshot. Change the name of the file that produces the snapshot and run it again. It will pass. Run `bazel test` and you will see info that says there is an obsolete snapshot

Any other information?

  1. We know jest_test is passing -u so that's good ✅ https://github.com/aspect-build/rules_jest/blob/main/jest/private/jest_test.bzl#L96
  2. rules_jest custom resolver under the hood
    resolveSnapshotPath: (testPath) => {
  3. default resolver from jest https://github.com/jestjs/jest/blob/aaf5315537e3ad02f93721e2e230df7bdcbccd43/packages/jest-snapshot/src/SnapshotResolver.ts#L59-L80
  4. Jest internally reads the snapshot resolver response using the custom functions via https://github.com/jestjs/jest/blob/main/packages/jest-snapshot/src/index.ts#L138 to determine what to cleanup
@Aghassi Aghassi added the bug Something isn't working label Jun 29, 2023
@github-actions github-actions bot added the untriaged Requires traige label Jun 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working untriaged Requires traige
Projects
Status: No status
Development

No branches or pull requests

1 participant