|
| 1 | +/* eslint-disable node/no-unpublished-import */ |
| 2 | + |
| 3 | +import { |
| 4 | + configureNextcloud, |
| 5 | + startNextcloud, |
| 6 | + stopNextcloud, |
| 7 | + waitOnNextcloud, |
| 8 | +} from './cypress/dockerNode' |
| 9 | +import { defineConfig } from 'cypress' |
| 10 | + |
| 11 | +import browserify from '@cypress/browserify-preprocessor' |
| 12 | + |
| 13 | +export default defineConfig({ |
| 14 | + projectId: 'okzqgr', |
| 15 | + |
| 16 | + // 16/9 screen ratio |
| 17 | + viewportWidth: 1280, |
| 18 | + viewportHeight: 720, |
| 19 | + |
| 20 | + // Tries again 2 more times on failure |
| 21 | + retries: { |
| 22 | + runMode: 2, |
| 23 | + // do not retry in `cypress open` |
| 24 | + openMode: 0, |
| 25 | + }, |
| 26 | + |
| 27 | + // Needed to trigger `after:run` events with cypress open |
| 28 | + experimentalInteractiveRunEvents: true, |
| 29 | + |
| 30 | + // faster video processing |
| 31 | + videoCompression: false, |
| 32 | + |
| 33 | + // Visual regression testing |
| 34 | + env: { |
| 35 | + failSilently: false, |
| 36 | + type: 'actual', |
| 37 | + }, |
| 38 | + |
| 39 | + screenshotsFolder: 'cypress/snapshots/actual', |
| 40 | + trashAssetsBeforeRuns: true, |
| 41 | + |
| 42 | + e2e: { |
| 43 | + testIsolation: false, |
| 44 | + |
| 45 | + // We've imported your old cypress plugins here. |
| 46 | + // You may want to clean this up later by importing these. |
| 47 | + async setupNodeEvents(on, config) { |
| 48 | + // Fix browserslist extend https://github.com/cypress-io/cypress/issues/2983#issuecomment-570616682 |
| 49 | + on('file:preprocessor', browserify({ typescript: require.resolve('typescript') })) |
| 50 | + |
| 51 | + // Disable spell checking to prevent rendering differences |
| 52 | + on('before:browser:launch', (browser, launchOptions) => { |
| 53 | + if (browser.family === 'chromium' && browser.name !== 'electron') { |
| 54 | + launchOptions.preferences.default['browser.enable_spellchecking'] = false |
| 55 | + return launchOptions |
| 56 | + } |
| 57 | + |
| 58 | + if (browser.family === 'firefox') { |
| 59 | + launchOptions.preferences['layout.spellcheckDefault'] = 0 |
| 60 | + return launchOptions |
| 61 | + } |
| 62 | + |
| 63 | + if (browser.name === 'electron') { |
| 64 | + launchOptions.preferences.spellcheck = false |
| 65 | + return launchOptions |
| 66 | + } |
| 67 | + }) |
| 68 | + |
| 69 | + // Remove container after run |
| 70 | + on('after:run', () => { |
| 71 | + stopNextcloud() |
| 72 | + }) |
| 73 | + |
| 74 | + // Before the browser launches |
| 75 | + // starting Nextcloud testing container |
| 76 | + return startNextcloud(process.env.BRANCH) |
| 77 | + .then((ip) => { |
| 78 | + // Setting container's IP as base Url |
| 79 | + config.baseUrl = `http://${ip}/index.php` |
| 80 | + return ip |
| 81 | + }) |
| 82 | + .then(waitOnNextcloud) |
| 83 | + .then(configureNextcloud) |
| 84 | + .then(() => { |
| 85 | + return config |
| 86 | + }) |
| 87 | + }, |
| 88 | + }, |
| 89 | + |
| 90 | + component: { |
| 91 | + devServer: { |
| 92 | + framework: 'vue', |
| 93 | + bundler: 'webpack', |
| 94 | + webpackConfig: async () => { |
| 95 | + process.env.npm_package_name = 'NcCypress' |
| 96 | + process.env.npm_package_version = '1.0.0' |
| 97 | + process.env.NODE_ENV = 'development' |
| 98 | + |
| 99 | + /** |
| 100 | + * Needed for cypress stubbing |
| 101 | + * |
| 102 | + * @see https://github.com/sinonjs/sinon/issues/1121 |
| 103 | + * @see https://github.com/cypress-io/cypress/issues/18662 |
| 104 | + */ |
| 105 | + const babel = require('./babel.config.js') |
| 106 | + babel.plugins.push([ |
| 107 | + '@babel/plugin-transform-modules-commonjs', |
| 108 | + { |
| 109 | + loose: true, |
| 110 | + }, |
| 111 | + ]) |
| 112 | + |
| 113 | + const config = require('@nextcloud/webpack-vue-config') |
| 114 | + config.module.rules.push({ |
| 115 | + test: /\.svg$/, |
| 116 | + type: 'asset/source', |
| 117 | + }) |
| 118 | + |
| 119 | + return config |
| 120 | + }, |
| 121 | + }, |
| 122 | + }, |
| 123 | +}) |
0 commit comments