Skip to content

Commit

Permalink
code to reproduce issue cypress-io/cypress#22825
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnnyFun committed Jul 19, 2022
0 parents commit 2142cd5
Show file tree
Hide file tree
Showing 14 changed files with 9,701 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/**/node_modules/
/cypress/screenshots
/test-output
30 changes: 30 additions & 0 deletions cypress-ci.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const cypress = require('cypress')
const fs = require('fs')
const path = require('path')

cypressRun(6001, 4001)

async function cypressRun(cypressPort) {
const runOptions = {
testingType: 'component',
// each run needs a unique port since we're running multiple cypress.run instances on the same machine
port: cypressPort,
spec: path.resolve('./src/MyComponent.spec.js'),
browser: 'chrome', // chrome sometimes fails to connect: https://github.com/cypress-io/cypress/issues/8986
headless: true, // chrome supports headless or headed: https://docs.cypress.io/guides/guides/launching-browsers.html#Electron-Browser
// headed: true, // if failing to start, set this to true, so can see if error in chrome runner
quiet: false,
config: {
reporter: 'junit',
reporterOptions: {
mochaFile: `test-output/[hash].xml`,
},
watchForFileChanges: false,
screenshotOnRunFailure: true,
video: false,
videoUploadOnPasses: false,
trashAssetsBeforeRuns: false,
},
}
await cypress.run(runOptions)
}
22 changes: 22 additions & 0 deletions cypress.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const { defineConfig } = require('cypress')

const webpackConfig = require('./webpack.config.js')
// const webpackPreprocessor = require('@cypress/webpack-preprocessor') // if I uninstall this package, I get a different error.
const supportFile = './cypress/support/cypressSupportFile.js'

module.exports = defineConfig({
video: false,
videoUploadOnPasses: false,
viewportHeight: 700,
viewportWidth: 1200,
defaultCommandTimeout: 6000,
component: {
supportFile,
specPattern: 'src/**/*spec.js',
devServer: {
bundler: 'webpack',
webpackConfig,
},
},
})

12 changes: 12 additions & 0 deletions cypress/support/component-index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>Components App</title>
</head>
<body>
<div data-cy-root></div>
</body>
</html>
21 changes: 21 additions & 0 deletions cypress/support/cypressSupportFile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// import './commands'
// import 'cypress-plugin-tab'
// import 'cypress-commands'

/**
* Workaround for the "Automatic publicPath is not supported in this browser" fail
*
* See https://github.com/cypress-io/cypress/issues/18435 for more
* details. Should be removed when cypress switches to webpack 5.
*/
const scripts = document.getElementsByTagName('script')
scripts[scripts.length - 1].src = ' ' // yes, thats a single space and not the empty string

Cypress.on('uncaught:exception', err => {
// ignore certain errors when testing
const isEmptyErrorMsg = err.message == null || err.message.trim() === ''
if (isEmptyErrorMsg) throw new Error('NO ERROR MESSAGE: ' + err.reason?.toString() + err.toString())

// don't fail test for failing to initialize WebGL--for some reason
if (/Failed to initialize WebGL/i.test(err.message)) return false
})
184 changes: 184 additions & 0 deletions failure output on my win11 machine.txt

Large diffs are not rendered by default.

Loading

0 comments on commit 2142cd5

Please sign in to comment.