MCPcopy Create free account
hub / github.com/vitest-dev/vitest / removeSnapshotFile

Function removeSnapshotFile

packages/browser/src/node/rpc.ts:278–290  ·  view source on GitHub ↗
(id)

Source from the content-addressed store, hash-verified

276 await fs.writeFile(id, content, 'utf-8')
277 },
278 async removeSnapshotFile(id) {
279 checkFileAccess(id)
280 if (!canWrite(project)) {
281 vitest.logger.error(
282 `[vitest] Cannot remove snapshot file "${id}". File writing is disabled because server is exposed to the internet, see https://vitest.dev/config/browser/api.`,
283 )
284 return
285 }
286 if (!existsSync(id)) {
287 throw new Error(`Snapshot file "${id}" does not exist.`)
288 }
289 await fs.unlink(id)
290 },
291 getBrowserFileSourceMap(id) {
292 const mod = globalServer.vite.moduleGraph.getModuleById(id)
293 const result = mod?.transformResult

Callers

nothing calls this directly

Calls 3

checkFileAccessFunction · 0.85
canWriteFunction · 0.85
errorMethod · 0.80

Tested by

no test coverage detected