1
0

cypress.config.ts 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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. videoCompression: false,
  28. // Visual regression testing
  29. env: {
  30. failSilently: false,
  31. type: 'actual',
  32. },
  33. screenshotsFolder: 'cypress/snapshots/actual',
  34. trashAssetsBeforeRuns: true,
  35. e2e: {
  36. // Disable session isolation
  37. testIsolation: false,
  38. // We've imported your old cypress plugins here.
  39. // You may want to clean this up later by importing these.
  40. async setupNodeEvents(on, config) {
  41. cypressSplit(on, config)
  42. on('file:preprocessor', webpackPreprocessor({ webpackOptions: webpackConfig as Configuration }))
  43. // Disable spell checking to prevent rendering differences
  44. on('before:browser:launch', (browser, launchOptions) => {
  45. if (browser.family === 'chromium' && browser.name !== 'electron') {
  46. launchOptions.preferences.default['browser.enable_spellchecking'] = false
  47. return launchOptions
  48. }
  49. if (browser.family === 'firefox') {
  50. launchOptions.preferences['layout.spellcheckDefault'] = 0
  51. return launchOptions
  52. }
  53. if (browser.name === 'electron') {
  54. launchOptions.preferences.spellcheck = false
  55. return launchOptions
  56. }
  57. })
  58. // Remove container after run
  59. on('after:run', () => {
  60. if (!process.env.CI) {
  61. stopNextcloud()
  62. }
  63. })
  64. // Before the browser launches
  65. // starting Nextcloud testing container
  66. const ip = await startNextcloud(process.env.BRANCH)
  67. // Setting container's IP as base Url
  68. config.baseUrl = `http://${ip}/index.php`
  69. await waitOnNextcloud(ip)
  70. await configureNextcloud()
  71. await applyChangesToNextcloud()
  72. // IMPORTANT: return the config otherwise cypress-split will not work
  73. return config
  74. },
  75. },
  76. component: {
  77. devServer: {
  78. framework: 'vue',
  79. bundler: 'webpack',
  80. webpackConfig: async () => {
  81. process.env.npm_package_name = 'NcCypress'
  82. process.env.npm_package_version = '1.0.0'
  83. process.env.NODE_ENV = 'development'
  84. /**
  85. * Needed for cypress stubbing
  86. *
  87. * @see https://github.com/sinonjs/sinon/issues/1121
  88. * @see https://github.com/cypress-io/cypress/issues/18662
  89. */
  90. const babel = require('./babel.config.js')
  91. babel.plugins.push([
  92. '@babel/plugin-transform-modules-commonjs',
  93. {
  94. loose: true,
  95. },
  96. ])
  97. const config = webpackConfig
  98. config.module.rules.push({
  99. test: /\.svg$/,
  100. type: 'asset/source',
  101. })
  102. return config
  103. },
  104. },
  105. },
  106. })