-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
cypress.config.js
40 lines (33 loc) · 1.2 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
/* eslint-disable no-console */
const { defineConfig } = require('cypress')
const got = require('got')
// Cypress tests in the "e2e" folder have access to
// the Cypress object and the bundled Cypress._ Lodash.
// The Cypress configuration does NOT and thus has
// to import any 3rd party libraries
const _ = require('lodash')
// This function is called when a project is opened or re-opened (e.g. due to
// the project's config changing)
module.exports = defineConfig({
fixturesFolder: false,
e2e: {
supportFile: false,
async setupNodeEvents (on, config) {
// let's fetch the list of users
const users = await got(
'https://jsonplaceholder.cypress.io/users?_limit=3'
).json()
// we are only interested in the username and ID fields
const userInfo = _.map(users, (user) => {
return _.pick(user, ['id', 'username', 'email'])
})
console.log('Fetched the following users for testing')
console.table(userInfo)
// then set it inside the config object under the environment
// which will make it available via Cypress.env("users")
// before the start of the tests
config.env.users = userInfo
return config
},
},
})