1
0

cypress.config.ts 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /* eslint-disable node/no-unpublished-import */
  2. import {
  3. applyChangesToNextcloud,
  4. configureNextcloud,
  5. startNextcloud,
  6. stopNextcloud,
  7. waitOnNextcloud,
  8. } from './cypress/dockerNode'
  9. import { defineConfig } from 'cypress'
  10. import browserify from '@cypress/browserify-preprocessor'
  11. export default defineConfig({
  12. projectId: '37xpdh',
  13. // 16/9 screen ratio
  14. viewportWidth: 1280,
  15. viewportHeight: 720,
  16. // Tries again 2 more times on failure
  17. retries: {
  18. runMode: 2,
  19. // do not retry in `cypress open`
  20. openMode: 0,
  21. },
  22. // Needed to trigger `after:run` events with cypress open
  23. experimentalInteractiveRunEvents: true,
  24. // faster video processing
  25. videoCompression: false,
  26. // Visual regression testing
  27. env: {
  28. failSilently: false,
  29. type: 'actual',
  30. },
  31. screenshotsFolder: 'cypress/snapshots/actual',
  32. trashAssetsBeforeRuns: true,
  33. e2e: {
  34. // Enable session management and disable isolation
  35. experimentalSessionAndOrigin: true,
  36. testIsolation: 'off',
  37. // We've imported your old cypress plugins here.
  38. // You may want to clean this up later by importing these.
  39. async setupNodeEvents(on, config) {
  40. // Fix browserslist extend https://github.com/cypress-io/cypress/issues/2983#issuecomment-570616682
  41. on('file:preprocessor', browserify({ typescript: require.resolve('typescript') }))
  42. // Disable spell checking to prevent rendering differences
  43. on('before:browser:launch', (browser, launchOptions) => {
  44. if (browser.family === 'chromium' && browser.name !== 'electron') {
  45. launchOptions.preferences.default['browser.enable_spellchecking'] = false
  46. return launchOptions
  47. }
  48. if (browser.family === 'firefox') {
  49. launchOptions.preferences['layout.spellcheckDefault'] = 0
  50. return launchOptions
  51. }
  52. if (browser.name === 'electron') {
  53. launchOptions.preferences.spellcheck = false
  54. return launchOptions
  55. }
  56. })
  57. // Remove container after run
  58. on('after:run', () => {
  59. if (!process.env.CI) {
  60. stopNextcloud()
  61. }
  62. })
  63. // Before the browser launches
  64. // starting Nextcloud testing container
  65. return startNextcloud(process.env.BRANCH)
  66. .then((ip) => {
  67. // Setting container's IP as base Url
  68. config.baseUrl = `http://${ip}/index.php`
  69. return ip
  70. })
  71. .then(waitOnNextcloud)
  72. .then(configureNextcloud)
  73. .then(applyChangesToNextcloud)
  74. .then(() => {
  75. return config
  76. })
  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 = require('@nextcloud/webpack-vue-config')
  101. config.module.rules.push({
  102. test: /\.svg$/,
  103. type: 'asset/source',
  104. })
  105. return config
  106. },
  107. },
  108. },
  109. })