aboutsummaryrefslogtreecommitdiffstats
path: root/cypress.config.ts
diff options
context:
space:
mode:
Diffstat (limited to 'cypress.config.ts')
-rw-r--r--cypress.config.ts56
1 files changed, 47 insertions, 9 deletions
diff --git a/cypress.config.ts b/cypress.config.ts
index d158d8cfae2..0b1a0524c9d 100644
--- a/cypress.config.ts
+++ b/cypress.config.ts
@@ -1,3 +1,15 @@
+/**
+ * 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,
@@ -5,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({
@@ -29,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'.
@@ -50,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') {
@@ -82,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)
@@ -90,7 +124,10 @@ export default defineConfig({
config.baseUrl = `http://${ip}/index.php`
await waitOnNextcloud(ip)
await configureNextcloud()
- await applyChangesToNextcloud()
+
+ if (!process.env.CI) {
+ await applyChangesToNextcloud()
+ }
// IMPORTANT: return the config otherwise cypress-split will not work
return config
@@ -98,6 +135,7 @@ export default defineConfig({
},
component: {
+ specPattern: ['core/**/*.cy.ts', 'apps/**/*.cy.ts'],
devServer: {
framework: 'vue',
bundler: 'webpack',