aspect-build / rules_jest

Bazel rules to run tests using https://jestjs.io
Apache License 2.0
23 stars 17 forks source link

[Bug]: InlineSnapshots don't work #193

Open Aghassi opened 10 months ago

Aghassi commented 10 months ago

What happened?

Jest allows users to write toMatchInlineSnapshots, which involves writing a snapshot to the source file instead of the snapshot file itself. However, in Bazel source files are write protected so when you run test_update_snapshots you will fail to write the inline snapshot and can't update thus can't update the snapshot. This makes inline snapshots unuseable with bazel basically.

https://jestjs.io/docs/snapshot-testing#inline-snapshots

Version

Development (host) and target OS/architectures: macOS

Output of bazel --version: 6.3.0

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

Language(s) and/or frameworks involved: rules_js rules_ts rules_jest rules_swc

How to reproduce

Have a workspace that has rules_jest setup
Write a test that calls `toMatchInlineSnapshot`
Run `test_update_snapshots` on it and see it fail with `EACCES: permission denied`

Any other information?

No response

Aghassi commented 10 months ago

Workarounds for this include using toStrictEqual or toMatchSnapshot. But basically, toMatchInlineSnapshot is not useable