diff options
Diffstat (limited to 'cypress.config.ts')
-rw-r--r-- | cypress.config.ts | 47 |
1 files changed, 39 insertions, 8 deletions
diff --git a/cypress.config.ts b/cypress.config.ts index 2c91c6256d5..0b1a0524c9d 100644 --- a/cypress.config.ts +++ b/cypress.config.ts @@ -2,6 +2,14 @@ * SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors * SPDX-License-Identifier: AGPL-3.0-or-later */ +import type { Configuration } from 'webpack' +import { defineConfig } from 'cypress' +import { join } from 'path' +import { removeDirectory } from 'cypress-delete-downloads-folder' + +import cypressSplit from 'cypress-split' +import webpackPreprocessor from '@cypress/webpack-preprocessor' + import { applyChangesToNextcloud, configureNextcloud, @@ -9,11 +17,6 @@ import { stopNextcloud, waitOnNextcloud, } from './cypress/dockerNode' -import { defineConfig } from 'cypress' -import cypressSplit from 'cypress-split' -import webpackPreprocessor from '@cypress/webpack-preprocessor' -import type { Configuration } from 'webpack' - import webpackConfig from './webpack.config.js' export default defineConfig({ @@ -33,8 +36,10 @@ export default defineConfig({ // Needed to trigger `after:run` events with cypress open experimentalInteractiveRunEvents: true, + // disabled if running in CI but enabled in debug mode + video: !process.env.CI || !!process.env.RUNNER_DEBUG, + // faster video processing - video: !process.env.CI, videoCompression: false, // Prevent elements to be scrolled under a top bar during actions (click, clear, type, etc). Default is 'top'. @@ -54,13 +59,28 @@ export default defineConfig({ // Disable session isolation testIsolation: false, + requestTimeout: 30000, + // We've imported your old cypress plugins here. // You may want to clean this up later by importing these. async setupNodeEvents(on, config) { - cypressSplit(on, config) - on('file:preprocessor', webpackPreprocessor({ webpackOptions: webpackConfig as Configuration })) + on('task', { removeDirectory }) + + // This allows to store global data (e.g. the name of a snapshot) + // because Cypress.env() and other options are local to the current spec file. + const data = {} + on('task', { + setVariable({ key, value }) { + data[key] = value + return null + }, + getVariable({ key }) { + return data[key] ?? null + }, + }) + // Disable spell checking to prevent rendering differences on('before:browser:launch', (browser, launchOptions) => { if (browser.family === 'chromium' && browser.name !== 'electron') { @@ -86,6 +106,16 @@ export default defineConfig({ } }) + // Check if we are running the setup checks + if (process.env.SETUP_TESTING === 'true') { + console.log('Adding setup tests to specPattern 🧮') + config.specPattern = [join(__dirname, 'cypress/e2e/core/setup.ts')] + console.log('└─ Done') + } else { + // If we are not running the setup tests, we need to remove the setup tests from the specPattern + cypressSplit(on, config) + } + // Before the browser launches // starting Nextcloud testing container const ip = await startNextcloud(process.env.BRANCH) @@ -105,6 +135,7 @@ export default defineConfig({ }, component: { + specPattern: ['core/**/*.cy.ts', 'apps/**/*.cy.ts'], devServer: { framework: 'vue', bundler: 'webpack', |