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

Function saveSnapshotFile

packages/browser/src/node/rpc.ts:254–264  ·  view source on GitHub ↗
(id, content)

Source from the content-addressed store, hash-verified

252 return fs.readFile(snapshotPath, 'utf-8')
253 },
254 async saveSnapshotFile(id, content) {
255 checkFileAccess(id)
256 if (!canWrite(project)) {
257 vitest.logger.error(
258 `[vitest] Cannot save snapshot file "${id}". File writing is disabled because server is exposed to the internet, see https://vitest.dev/config/browser/api.`,
259 )
260 return
261 }
262 await fs.mkdir(dirname(id), { recursive: true })
263 await fs.writeFile(id, content, 'utf-8')
264 },
265 async removeSnapshotFile(id) {
266 checkFileAccess(id)
267 if (!canWrite(project)) {

Callers

nothing calls this directly

Calls 3

checkFileAccessFunction · 0.85
canWriteFunction · 0.85
errorMethod · 0.80

Tested by

no test coverage detected