-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Open
Labels
angular/build:unit-testarea: @angular/buildfreq1: lowOnly reported by a handful of users who observe it rarelyOnly reported by a handful of users who observe it rarelyseverity3: brokentype: bug/fix
Description
Command
test
Description
Snapshot testing with Vitest is currently not supported.
The inline snapshots throw an error, and the file snapshots are stored in the dist folder which defeats the purpose of snapshot testing since these are not commited.
As an example see https://github.com/timdeschryver/VitestAngular/blob/main/src/app/app.spec.ts#L16.
Running the tests throws the following error:
TypeError: Cannot read properties of null (reading 'length')
❯ new MagicString ../../../node_modules/magic-string/src/MagicString.js:21:37
❯ ../../../node_modules/@vitest/snapshot/dist/index.js:1422:13
❯ saveInlineSnapshots ../../../node_modules/@vitest/snapshot/dist/index.js:1419:2
❯ SnapshotState.save ../../../node_modules/@vitest/snapshot/dist/index.js:1956:5
❯ SnapshotState.pack ../../../node_modules/@vitest/snapshot/dist/index.js:2107:18
❯ SnapshotClient.finish ../../../node_modules/@vitest/snapshot/dist/index.js:2149:18
❯ VitestTestRunner.onAfterRunSuite ../../../node_modules/vitest/dist/runners.js:162:19
❯ runSuite ../../../node_modules/@vitest/runner/dist/index.js:1537:3
❯ runFiles ../../../node_modules/@vitest/runner/dist/index.js:1561:3
Describe the solution you'd like
I'd like to be able to use Vitest's snapshot testing.
Describe alternatives you've considered
No response
LanderBeeuwsaert and marcindz88
Metadata
Metadata
Assignees
Labels
angular/build:unit-testarea: @angular/buildfreq1: lowOnly reported by a handful of users who observe it rarelyOnly reported by a handful of users who observe it rarelyseverity3: brokentype: bug/fix