Skip to content

Commit

Permalink
fix(server): use run#run instead of run#ready to replicate e2e exit b…
Browse files Browse the repository at this point in the history
…ehavior in CT (cypress-io#17894)

Co-authored-by: Zach Bloomquist <[email protected]>
  • Loading branch information
lmiller1990 and flotwig authored Aug 26, 2021
1 parent a99caea commit ea287d7
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 9 deletions.
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)
}

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

0 comments on commit ea287d7

Please sign in to comment.