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

Method clearTest

packages/snapshot/src/port/state.ts:153–176  ·  view source on GitHub ↗
(testId: string)

Source from the content-addressed store, hash-verified

151 }
152
153 clearTest(testId: string): void {
154 // clear inline
155 this._inlineSnapshots = this._inlineSnapshots.filter(s => s.testId !== testId)
156 this._inlineSnapshotStacks = this._inlineSnapshotStacks.filter(s => s.testId !== testId)
157
158 // clear file
159 for (const key of this._testIdToKeys.get(testId)) {
160 const name = keyToTestName(key)
161 const count = this._counters.get(name)
162 if (count > 0) {
163 if (key in this._snapshotData || key in this._initialData) {
164 this._snapshotData[key] = this._initialData[key]
165 }
166 this._counters.set(name, count - 1)
167 }
168 }
169 this._testIdToKeys.delete(testId)
170
171 // clear stats
172 this.added.delete(testId)
173 this.updated.delete(testId)
174 this.matched.delete(testId)
175 this.unmatched.delete(testId)
176 }
177
178 protected _inferInlineSnapshotStack(stacks: ParsedStack[]): ParsedStack | null {
179 // if called inside resolves/rejects, stacktrace is different

Callers

nothing calls this directly

Calls 5

keyToTestNameFunction · 0.90
filterMethod · 0.65
getMethod · 0.45
setMethod · 0.45
deleteMethod · 0.45

Tested by

no test coverage detected