-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
snapshot-environment.ts
45 lines (36 loc) · 1.24 KB
/
snapshot-environment.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import { relative as _relative } from 'pathe'
import { VitestSnapshotEnvironment } from 'vitest/snapshot'
function relative(file: string) {
return _relative(process.cwd(), file)
}
class CustomSnapshotEnvironment extends VitestSnapshotEnvironment {
getVersion(): string {
console.log('## getVersion')
return super.getVersion()
}
getHeader() {
console.log('## getHeader')
return super.getHeader()
}
resolvePath(filepath: string) {
console.log('## resolvePath', relative(filepath))
return super.resolvePath(filepath)
}
resolveRawPath(testPath: string, rawPath: string) {
console.log('## resolveRawPath', relative(testPath), relative(rawPath))
return super.resolveRawPath(testPath, rawPath)
}
saveSnapshotFile(filepath: string, snapshot: string) {
console.log('## saveSnapshotFile', relative(filepath))
return super.saveSnapshotFile(filepath, snapshot)
}
readSnapshotFile(filepath: string) {
console.log('## readSnapshotFile', relative(filepath))
return super.readSnapshotFile(filepath)
}
removeSnapshotFile(filepath: string) {
console.log('## removeSnapshotFile', relative(filepath))
return super.removeSnapshotFile(filepath)
}
}
export default new CustomSnapshotEnvironment()