Skip to content

Commit ea287d7

Browse files
lmiller1990flotwig
andauthored
fix(server): use run#run instead of run#ready to replicate e2e exit behavior in CT (#17894)
Co-authored-by: Zach Bloomquist <git@chary.us>
1 parent a99caea commit ea287d7

File tree

8 files changed

+50
-9
lines changed

8 files changed

+50
-9
lines changed

circle.yml

+2
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,7 @@ commands:
373373
PERCY_ENABLE=${PERCY_TOKEN:-0} \
374374
PERCY_PARALLEL_TOTAL=-1 \
375375
$cmd yarn workspace @packages/runner cypress:run --record --parallel --group runner-integration-<<parameters.browser>> --browser <<parameters.browser>>
376+
- verify-mocha-results
376377
- store_test_results:
377378
path: /tmp/cypress
378379
- store_artifacts:
@@ -407,6 +408,7 @@ commands:
407408
else
408409
echo "skipping percy screenshots uploading"
409410
fi
411+
- verify-mocha-results
410412
- store_test_results:
411413
path: /tmp/cypress
412414
- store_artifacts:

packages/runner-ct/cypress.json

+4
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,9 @@
33
"video": true,
44
"env": {
55
"reactDevtools": true
6+
},
7+
"reporter": "../../node_modules/cypress-multi-reporters/index.js",
8+
"reporterOptions": {
9+
"configFile": "../../mocha-reporter-config.json"
610
}
711
}

packages/runner/cypress.json

+4
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,9 @@
44
"retries": {
55
"runMode": 2,
66
"openMode": 0
7+
},
8+
"reporter": "../../node_modules/cypress-multi-reporters/index.js",
9+
"reporterOptions": {
10+
"configFile": "../../mocha-reporter-config.json"
711
}
812
}

packages/server/lib/modes/run-ct.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@ const run = (options) => {
1717
})
1818
})
1919

20-
// if we're in run mode with component
21-
// testing then just pass this through
22-
// without waiting on electron to be ready
23-
return require('./run').ready(options)
20+
return require('./run').run(options)
2421
}
2522

2623
module.exports = {
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
const e2e = require('../support/helpers/e2e').default
2+
3+
describe('run-ct', () => {
4+
e2e.setup()
5+
6+
e2e.it('reports correct exit code when failing', {
7+
spec: 'simple_failing_spec.js',
8+
testingType: 'component',
9+
snapshot: false,
10+
expectedExitCode: 2,
11+
})
12+
})
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/* eslint-disable no-undef */
2+
describe('simple failing spec', () => {
3+
it('fails1', () => {
4+
cy.wrap(true, { timeout: 100 }).should('be.false')
5+
})
6+
7+
it('fails2', () => {
8+
throw new Error('fails2')
9+
})
10+
})

packages/server/test/support/fixtures/projects/e2e/cypress/plugins/index.js

+13-2
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,23 @@ const path = require('path')
66
const Promise = require('bluebird')
77
const { useFixedBrowserLaunchSize } = require('../../../utils')
88

9+
const { startDevServer } = require('@cypress/webpack-dev-server')
10+
11+
const webpackConfig = {
12+
output: {
13+
publicPath: '/',
14+
},
15+
devServer: {
16+
publicPath: '/',
17+
},
18+
}
19+
920
/**
1021
* @type {Cypress.PluginConfig}
1122
*/
1223
module.exports = (on, config) => {
13-
if (config.testingType !== 'e2e') {
14-
throw Error(`This is an e2e testing project. testingType should be 'e2e'. Received ${config.testingType}`)
24+
if (config.testingType === 'component') {
25+
on('dev-server:start', (options) => startDevServer({ options, webpackConfig }))
1526
}
1627

1728
let performance = {

packages/server/test/support/helpers/e2e.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -534,8 +534,9 @@ const e2e = {
534534
return spec
535535
}
536536

537-
// TODO would not work for component tests
538-
return path.join(options.project, 'cypress', 'integration', spec)
537+
const specDir = options.testingType === 'component' ? 'component' : 'integration'
538+
539+
return path.join(options.project, 'cypress', specDir, spec)
539540
})
540541

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

558559
if (options.testingType === 'component') {

0 commit comments

Comments
 (0)