Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(server): use run#run instead of run#ready to replicate e2e exit behavior in CT #17894

Merged
merged 7 commits into from
Aug 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ commands:
PERCY_ENABLE=${PERCY_TOKEN:-0} \
PERCY_PARALLEL_TOTAL=-1 \
$cmd yarn workspace @packages/runner cypress:run --record --parallel --group runner-integration-<<parameters.browser>> --browser <<parameters.browser>>
- verify-mocha-results
- store_test_results:
path: /tmp/cypress
- store_artifacts:
Expand Down Expand Up @@ -407,6 +408,7 @@ commands:
else
echo "skipping percy screenshots uploading"
fi
- verify-mocha-results
- store_test_results:
path: /tmp/cypress
- store_artifacts:
Expand Down
4 changes: 4 additions & 0 deletions packages/runner-ct/cypress.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,9 @@
"video": true,
"env": {
"reactDevtools": true
},
"reporter": "../../node_modules/cypress-multi-reporters/index.js",
"reporterOptions": {
"configFile": "../../mocha-reporter-config.json"
}
}
4 changes: 4 additions & 0 deletions packages/runner/cypress.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,9 @@
"retries": {
"runMode": 2,
"openMode": 0
},
"reporter": "../../node_modules/cypress-multi-reporters/index.js",
"reporterOptions": {
"configFile": "../../mocha-reporter-config.json"
}
}
5 changes: 1 addition & 4 deletions packages/server/lib/modes/run-ct.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ const run = (options) => {
})
})

// if we're in run mode with component
// testing then just pass this through
// without waiting on electron to be ready
return require('./run').ready(options)
return require('./run').run(options)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}

module.exports = {
Expand Down
12 changes: 12 additions & 0 deletions packages/server/test/e2e/7_run_ct_spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const e2e = require('../support/helpers/e2e').default

describe('run-ct', () => {
e2e.setup()

e2e.it('reports correct exit code when failing', {
spec: 'simple_failing_spec.js',
testingType: 'component',
snapshot: false,
expectedExitCode: 2,
})
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/* eslint-disable no-undef */
describe('simple failing spec', () => {
it('fails1', () => {
cy.wrap(true, { timeout: 100 }).should('be.false')
})

it('fails2', () => {
throw new Error('fails2')
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,23 @@ const path = require('path')
const Promise = require('bluebird')
const { useFixedBrowserLaunchSize } = require('../../../utils')

const { startDevServer } = require('@cypress/webpack-dev-server')

const webpackConfig = {
output: {
publicPath: '/',
},
devServer: {
publicPath: '/',
},
}

/**
* @type {Cypress.PluginConfig}
*/
module.exports = (on, config) => {
if (config.testingType !== 'e2e') {
throw Error(`This is an e2e testing project. testingType should be 'e2e'. Received ${config.testingType}`)
if (config.testingType === 'component') {
on('dev-server:start', (options) => startDevServer({ options, webpackConfig }))
}

let performance = {
Expand Down
7 changes: 4 additions & 3 deletions packages/server/test/support/helpers/e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -534,8 +534,9 @@ const e2e = {
return spec
}

// TODO would not work for component tests
return path.join(options.project, 'cypress', 'integration', spec)
const specDir = options.testingType === 'component' ? 'component' : 'integration'

return path.join(options.project, 'cypress', specDir, spec)
})

// normalize the path to the spec
Expand All @@ -552,7 +553,7 @@ const e2e = {
// hides a user warning to go through NPM module
`--cwd=${process.cwd()}`,
`--run-project=${options.project}`,
`--testingType=e2e`,
`--testingType=${options.testingType || 'e2e'}`,
]

if (options.testingType === 'component') {
Expand Down