cypress.config.ts 2.3 KB

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