You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

cypress.config.ts 3.3KB

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