-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathcypress.config.ts
More file actions
90 lines (78 loc) · 2.49 KB
/
cypress.config.ts
File metadata and controls
90 lines (78 loc) · 2.49 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import { defineConfig } from "cypress"
import { existsSync } from "fs"
import path from "path"
import { fileURLToPath } from "url"
import { dirname } from "path"
import { config as loadEnv } from "dotenv"
const __filename = fileURLToPath(import.meta.url)
const __dirname = dirname(__filename)
const baseEnvPath = path.resolve(__dirname, ".env")
const localEnvPath = path.resolve(__dirname, ".env.local")
if (existsSync(baseEnvPath)) {
loadEnv({ path: baseEnvPath })
}
if (existsSync(localEnvPath)) {
loadEnv({ path: localEnvPath, override: true })
}
export default defineConfig({
env: {
NEXTAUTH_SECRET: process.env.NEXTAUTH_SECRET,
},
viewportWidth: 1920,
viewportHeight: 1080,
e2e: {
async setupNodeEvents(on, config) {
process.env.CYPRESS = "true"
const { default: installLogsPrinter } = await import("cypress-terminal-report/src/installLogsPrinter")
const { resetTestDb: resetTestDatabase } = await import("./prisma/resetTestDb")
installLogsPrinter(on)
on("task", {
async resetTestDb() {
await resetTestDatabase()
return null
},
})
on("before:spec", async () => {
await resetTestDatabase()
})
on("before:browser:launch", (browser, launchOptions) => {
const width = 1920
const height = 1080
if (browser.name === "chrome" && browser.isHeadless) {
launchOptions.args.push(`--window-size=${width},${height}`)
launchOptions.args.push("--force-device-scale-factor=1")
}
if (browser.name === "electron" && browser.isHeadless) {
launchOptions.preferences.width = width
launchOptions.preferences.height = height
}
if (browser.name === "firefox" && browser.isHeadless) {
launchOptions.args.push(`--width=${width}`)
launchOptions.args.push(`--height=${height}`)
}
return launchOptions
})
},
baseUrl: "http://localhost:3000",
},
component: {
async setupNodeEvents(on, config) {
const { default: installLogsPrinter } = await import("cypress-terminal-report/src/installLogsPrinter")
installLogsPrinter(on, { printLogsToConsole: "onFail" })
},
devServer: {
framework: "next",
bundler: "webpack",
webpackConfig: {
devServer: {
allowedHosts: "all",
},
resolve: {
alias: {
"@components": path.resolve(__dirname, "./src/components"),
},
},
},
},
},
})