-
-
Notifications
You must be signed in to change notification settings - Fork 31
/
cypress.config.ts
33 lines (32 loc) · 1.11 KB
/
cypress.config.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
import { defineConfig } from 'cypress'
import { copyFileSync, readFileSync, renameSync, writeFileSync } from 'fs'
export default defineConfig({
e2e: {
baseUrl: 'http://localhost:8938',
specPattern: 'cypress/integration/**/*.test.ts',
supportFile: false,
setupNodeEvents(on) {
on('task', {
keepOriginal(paths: string | string[]) {
return (Array.isArray(paths) ? paths : [paths]).map((path) => {
const tmpFileName = `${path}.tmp`
copyFileSync(path, tmpFileName)
return tmpFileName
})
},
restoreOriginal(paths: string | string[]) {
return (Array.isArray(paths) ? paths : [paths]).map((path) => {
const tmpFileName = `${path}.tmp`
renameSync(tmpFileName, path)
return path
})
},
amendFile({ path, target, replacement }: { path: string; target: string; replacement: string }) {
const original = readFileSync(path).toString()
writeFileSync(path, original.replace(target, replacement))
return path
},
})
},
},
})