-
Notifications
You must be signed in to change notification settings - Fork 157
/
Copy pathconfig.js
48 lines (43 loc) · 1.24 KB
/
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
46
47
48
const { defineConfig } = require( 'cypress' );
const { readConfig } = require( '@wordpress/env/lib/config' );
module.exports = defineConfig( {
chromeWebSecurity: false,
fixturesFolder: 'tests/cypress/fixtures',
screenshotsFolder: 'tests/cypress/screenshots',
videosFolder: 'tests/cypress/videos',
downloadsFolder: 'tests/cypress/downloads',
video: true,
reporter: 'mochawesome',
reporterOptions: {
mochaFile: 'mochawesome-[name]',
reportDir: __dirname + '/reports',
overwrite: false,
html: false,
json: true,
},
e2e: {
setupNodeEvents( on, config ) {
return setBaseUrl( on, config );
},
specPattern: 'tests/cypress/e2e/**/*.test.{js,jsx,ts,tsx}',
supportFile: 'tests/cypress/support/e2e.js',
defaultCommandTimeout: 20000,
},
} );
/**
* Set WP URL as baseUrl in Cypress config.
*
* @param {Function} on function that used to register listeners on various events.
* @param {Object} config Cypress Config object.
* @return {Object} Updated Cypress Config object.
*/
const setBaseUrl = async ( on, config ) => {
const wpEnvConfig = await readConfig( 'wp-env' );
if ( wpEnvConfig ) {
const port = wpEnvConfig.env.tests.port || null;
if ( port ) {
config.baseUrl = 'http://localhost:80/';
}
}
return config;
};