-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
cypress.config.js
45 lines (36 loc) · 1.08 KB
/
cypress.config.js
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
/* eslint-disable no-console */
const { defineConfig } = require('cypress')
module.exports = defineConfig({
fixturesFolder: false,
e2e: {
supportFile: false,
setupNodeEvents (on, config) {
const items = {}
// cy.task() requires returning a Promise
// or anything BUT undefined to signal that
// the task is finished
// see https://on.cypress.io/task
on('task', {
setItem ({ name, value }) {
console.log('setting %s', name)
if (typeof value === 'undefined') {
// since we cannot return undefined from the cy.task
// let's not allow storing undefined
throw new Error(`Cannot store undefined value for item "${name}"`)
}
items[name] = value
return null
},
getItem (name) {
if (name in items) {
console.log('returning item %s', name)
return items[name]
}
const msg = `Missing item "${name}"`
console.error(msg)
throw new Error(msg)
},
})
},
},
})