MCPcopy
hub / github.com/vitest-dev/vitest / assertRaw

Method assertRaw

packages/snapshot/src/client.ts:348–375  ·  view source on GitHub ↗
(options: AssertOptions)

Source from the content-addressed store, hash-verified

346 }
347
348 async assertRaw(options: AssertOptions): Promise<void> {
349 if (!options.rawSnapshot) {
350 throw new Error('Raw snapshot is required')
351 }
352
353 const { filepath, rawSnapshot } = options
354
355 if (rawSnapshot.content == null) {
356 if (!filepath) {
357 throw new Error('Snapshot cannot be used outside of test')
358 }
359
360 const snapshotState = this.getSnapshotState(filepath)
361
362 // save the filepath, so it don't lose even if the await make it out-of-context
363 options.filepath ||= filepath
364 // resolve and read the raw snapshot file
365 rawSnapshot.file = await snapshotState.environment.resolveRawPath(
366 filepath,
367 rawSnapshot.file,
368 )
369 rawSnapshot.content
370 = (await snapshotState.environment.readSnapshotFile(rawSnapshot.file))
371 ?? undefined
372 }
373
374 return this.assert(options)
375 }
376
377 clear(): void {
378 this.snapshotStateMap.clear()

Callers

nothing calls this directly

Calls 4

getSnapshotStateMethod · 0.95
assertMethod · 0.95
resolveRawPathMethod · 0.45
readSnapshotFileMethod · 0.45

Tested by

no test coverage detected