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

feat!: move snapshot implementation into @vitest/snapshot #3032

Merged
merged 15 commits into from
Mar 29, 2023
Prev Previous commit
Next Next commit
chore: cleanup
  • Loading branch information
sheremet-va committed Mar 29, 2023
commit fcc541cd2e6374406e7e629666928e4a8e912194
3 changes: 2 additions & 1 deletion packages/snapshot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,11 @@ const options = {
await client.setTest(getCurrentFilepath(), getCurrentTestName(), options)

// uses pretty-format, so it requires quotes
// also naming is hard coded when parsing test files
wrapper('text 1').toMatchInlineSnapshot('"text 1"')
wrapper('text 2').toMatchInlineSnapshot('"text 2"')

const result = await client.resetCurrent() // returns SnapshotResult
const result = await client.resetCurrent() // this saves files and returns SnapshotResult

// you can use manager to manage several clients
const manager = new SnapshotManager(options)
Expand Down
3 changes: 2 additions & 1 deletion packages/vitest/src/runtime/runners/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { getFullName, getNames, getWorkerState } from '../../utils'
import { createExpect } from '../../integrations/chai/index'
import type { ResolvedConfig } from '../../types/config'
import type { VitestExecutor } from '../execute'
import { rpc } from '../rpc'

export class VitestTestRunner implements VitestRunner {
private snapshotClient = getSnapshotClient()
Expand All @@ -27,7 +28,7 @@ export class VitestTestRunner implements VitestRunner {
async onAfterRun() {
const result = await this.snapshotClient.resetCurrent()
if (result)
await this.workerState.rpc.snapshotSaved(result)
await rpc().snapshotSaved(result)
}

onAfterRunSuite(suite: Suite) {
Expand Down