Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Export snapshot state to
expect.extend
. (#1378)
- Loading branch information
Showing
9 changed files
with
1,185 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Vitest Demo | ||
|
||
Run `npm test` and change a test or source code to see HMR in action! | ||
|
||
Learn more at https://vitest.dev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"name": "@vitest/example-image-snapshot", | ||
"type": "module", | ||
"private": true, | ||
"license": "MIT", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "vitest", | ||
"test:ui": "vitest --ui", | ||
"test:run": "vitest run" | ||
}, | ||
"devDependencies": { | ||
"@vitest/ui": "latest", | ||
"jest-image-snapshot": "^4.5.1", | ||
"vite": "^2.9.9", | ||
"vitest": "latest" | ||
}, | ||
"stackblitz": { | ||
"startCommand": "npm run test:ui" | ||
} | ||
} |
Binary file added
BIN
+5.2 KB
..._snapshots__/basic-test-ts-test-basic-test-ts-2-m-22-mimage-snapshot-1-snap.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { readFileSync } from 'fs' | ||
import { expect, test } from 'vitest' | ||
import { toMatchImageSnapshot } from 'jest-image-snapshot' | ||
|
||
declare global { | ||
namespace jest { | ||
interface Matchers<R> { | ||
toMatchImageSnapshot(): R | ||
} | ||
} | ||
} | ||
|
||
expect.extend({ toMatchImageSnapshot }) | ||
|
||
test('image snapshot', () => { | ||
expect(readFileSync('./test/stubs/input-image.png')).toMatchImageSnapshot() | ||
}) |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/// <reference types="vitest" /> | ||
|
||
// Configure Vitest (https://vitest.dev/config/) | ||
|
||
import { defineConfig } from 'vite' | ||
|
||
export default defineConfig({ | ||
test: { | ||
/* for example, use global to avoid globals imports (describe, test, expect): */ | ||
// globals: true, | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.