-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
46 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,18 @@ | ||
const { defineConfig } = require('cypress'); | ||
const path = require('path'); | ||
|
||
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: path.join(__dirname, 'reports'), | ||
overwrite: false, | ||
html: false, | ||
json: true, | ||
}, | ||
fixturesFolder: `${__dirname}/fixtures`, | ||
screenshotsFolder: `${__dirname}/screenshots`, | ||
videosFolder: `${__dirname}/videos`, | ||
downloadsFolder: `${__dirname}/downloads`, | ||
video: false, | ||
e2e: { | ||
specPattern: 'tests/cypress/e2e/**/*.cy.{js,jsx,ts,tsx}', | ||
supportFile: 'tests/cypress/support/index.js', | ||
setupNodeEvents(on, config) { | ||
// eslint-disable-next-line import/no-dynamic-require, global-require | ||
return require(`${__dirname}/plugins/index.js`)(on, config); | ||
}, | ||
specPattern: `${__dirname}/e2e/*.test.{js,jsx,ts,tsx}`, | ||
supportFile: `${__dirname}/support/index.js`, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/// <reference types="cypress" /> | ||
// *********************************************************** | ||
// This example plugins/index.js can be used to load plugins | ||
// | ||
// You can change the location of this file or turn off loading | ||
// the plugins file with the 'pluginsFile' configuration option. | ||
// | ||
// You can read more here: | ||
// https://on.cypress.io/plugins-guide | ||
// *********************************************************** | ||
|
||
// This function is called when a project is opened or re-opened (e.g. due to | ||
// the project's config changing) | ||
|
||
const { loadConfig } = require('@wordpress/env/lib/config'); | ||
const getCacheDirectory = require('@wordpress/env/lib/config/get-cache-directory'); | ||
|
||
/** | ||
* @type {Cypress.PluginConfig} | ||
*/ | ||
// eslint-disable-next-line no-unused-vars | ||
module.exports = async (on, config) => { | ||
const cacheDirectory = await getCacheDirectory(); | ||
const wpEnvConfig = await loadConfig(cacheDirectory); | ||
|
||
if (wpEnvConfig) { | ||
const port = wpEnvConfig.env.tests.port || null; | ||
|
||
if (port) { | ||
config.baseUrl = wpEnvConfig.env.tests.config.WP_SITEURL; | ||
} | ||
} | ||
|
||
return config; | ||
}; |