-
Notifications
You must be signed in to change notification settings - Fork 4
/
cypress.config.ts
48 lines (41 loc) · 1.42 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/* eslint-disable import/no-default-export,@typescript-eslint/no-unused-vars,@typescript-eslint/no-misused-promises */
import { defineConfig } from 'cypress'
import http from 'http'
import next from 'next'
// TODO: .env
const BASE_URL = 'http://localhost:3000'
const NEXT_PUBLIC_API_URL = 'https://testproject-api-v2.strv.com/'
export default defineConfig({
e2e: {
baseUrl: BASE_URL,
setupNodeEvents: async (on, config) => {
config.env.api_url = NEXT_PUBLIC_API_URL
const app = next({ dev: true })
const handleNextRequests = app.getRequestHandler()
await app.prepare()
const customServer = new http.Server(async (req, res) => {
return await handleNextRequests(req, res)
})
await new Promise<void>((resolve) => {
customServer.listen(3000, () => {
console.log(`> Ready on ${BASE_URL}`)
resolve()
})
})
// We are not actually fetching events on server. But you can intercept requests with nock
// https://glebbahmutov.com/blog/mock-network-from-server/
// on('task', {
// clearNock() {
// nock.restore()
// nock.cleanAll()
// },
//
// nock(hostname: string, method: 'get' | 'post', path: string, statusCode: number, body: any) {
// nock.activate()
// nock(hostname)[method](path).reply(statusCode, body)
// },
// })
return config
},
},
})