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

Function removeSnapshotFile

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

Source from the content-addressed store, hash-verified

263 await fs.writeFile(id, content, 'utf-8')
264 },
265 async removeSnapshotFile(id) {
266 checkFileAccess(id)
267 if (!canWrite(project)) {
268 vitest.logger.error(
269 `[vitest] Cannot remove snapshot file "${id}". File writing is disabled because server is exposed to the internet, see https://vitest.dev/config/browser/api.`,
270 )
271 return
272 }
273 if (!existsSync(id)) {
274 throw new Error(`Snapshot file "${id}" does not exist.`)
275 }
276 await fs.unlink(id)
277 },
278 getBrowserFileSourceMap(id) {
279 const mod = globalServer.vite.moduleGraph.getModuleById(id)
280 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