mirror of
https://github.com/hanzoai/vitest.git
synced 2026-10-30 14:46:34 +00:00
46 lines
1.2 KiB
TypeScript
46 lines
1.2 KiB
TypeScript
import { relative as _relative } from 'pathe'
|
|
import { VitestSnapshotEnvironment } from 'vitest/runtime'
|
|
|
|
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()
|