1
0

cypress.config.ts 3.2 KB

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