cypress.config.ts 3.0 KB

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