[READ-ONLY] Mirror of https://github.com/vitest-dev/vitest. Next generation testing framework powered by Vite. vitest.dev
test testing-tools vite
12

Configure Feed

Select the types of activity you want to include in your feed.

fix(snapshot): fix `toMatchFileSnapshot` with empty file (#5894)

authored by

Hiroshi Ogawa and committed by
GitHub
(Jun 16, 2024, 9:20 AM +0300) 8800601d 64e200d2

+5 -1
+1 -1
packages/snapshot/src/client.ts
··· 159 159 options.filepath ||= filepath 160 160 // resolve and read the raw snapshot file 161 161 rawSnapshot.file = await snapshotState.environment.resolveRawPath(filepath, rawSnapshot.file) 162 - rawSnapshot.content = await snapshotState.environment.readSnapshotFile(rawSnapshot.file) || undefined 162 + rawSnapshot.content = await snapshotState.environment.readSnapshotFile(rawSnapshot.file) ?? undefined 163 163 } 164 164 165 165 return this.assert(options)
+4
test/core/test/snapshot-file.test.ts
··· 18 18 }) 19 19 } 20 20 }) 21 + 22 + test('handle empty file', () => { 23 + expect('').toMatchFileSnapshot('./fixtures/snapshot-empty.txt') 24 + })
test/core/test/fixtures/snapshot-empty.txt