mirror of
https://github.com/cypress-io/cypress.git
synced 2026-02-23 07:39:52 -06:00
fix: exception when recording with no tests in specfile (#15517)
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
{
|
||||
"projectId": "2pz86o"
|
||||
}
|
||||
|
||||
@@ -2531,3 +2531,98 @@ exports['e2e record api skips specs records tests and exits without executing in
|
||||
Exiting with non-zero exit code because the run was canceled.
|
||||
|
||||
`
|
||||
|
||||
exports['e2e record empty specs succeeds when empty spec file 1'] = `
|
||||
|
||||
====================================================================================================
|
||||
|
||||
(Run Starting)
|
||||
|
||||
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
|
||||
│ Cypress: 1.2.3 │
|
||||
│ Browser: FooBrowser 88 │
|
||||
│ Specs: 2 found (empty_suite.spec.js, empty.spec.js) │
|
||||
│ Searched: cypress/integration/empty_suite.spec.js, cypress/integration/empty.spec.js │
|
||||
│ Params: Tag: false, Group: false, Parallel: false │
|
||||
│ Run URL: https://dashboard.cypress.io/projects/cjvoj7/runs/12 │
|
||||
└────────────────────────────────────────────────────────────────────────────────────────────────┘
|
||||
|
||||
|
||||
────────────────────────────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
Running: empty_suite.spec.js (1 of 2)
|
||||
Estimated: 8 seconds
|
||||
|
||||
|
||||
0 passing
|
||||
|
||||
|
||||
(Results)
|
||||
|
||||
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
|
||||
│ Tests: 0 │
|
||||
│ Passing: 0 │
|
||||
│ Failing: 0 │
|
||||
│ Pending: 0 │
|
||||
│ Skipped: 0 │
|
||||
│ Screenshots: 0 │
|
||||
│ Video: true │
|
||||
│ Duration: X seconds │
|
||||
│ Estimated: 8 seconds │
|
||||
│ Spec Ran: empty_suite.spec.js │
|
||||
└────────────────────────────────────────────────────────────────────────────────────────────────┘
|
||||
|
||||
|
||||
(Uploading Results)
|
||||
|
||||
- Nothing to Upload
|
||||
|
||||
────────────────────────────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
Running: empty.spec.js (2 of 2)
|
||||
Estimated: 8 seconds
|
||||
|
||||
|
||||
0 passing
|
||||
|
||||
|
||||
(Results)
|
||||
|
||||
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
|
||||
│ Tests: 0 │
|
||||
│ Passing: 0 │
|
||||
│ Failing: 0 │
|
||||
│ Pending: 0 │
|
||||
│ Skipped: 0 │
|
||||
│ Screenshots: 0 │
|
||||
│ Video: true │
|
||||
│ Duration: X seconds │
|
||||
│ Estimated: 8 seconds │
|
||||
│ Spec Ran: empty.spec.js │
|
||||
└────────────────────────────────────────────────────────────────────────────────────────────────┘
|
||||
|
||||
|
||||
(Uploading Results)
|
||||
|
||||
- Nothing to Upload
|
||||
|
||||
====================================================================================================
|
||||
|
||||
(Run Finished)
|
||||
|
||||
|
||||
Spec Tests Passing Failing Pending Skipped
|
||||
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
|
||||
│ ✔ empty_suite.spec.js XX:XX - - - - - │
|
||||
├────────────────────────────────────────────────────────────────────────────────────────────────┤
|
||||
│ ✔ empty.spec.js XX:XX - - - - - │
|
||||
└────────────────────────────────────────────────────────────────────────────────────────────────┘
|
||||
✔ All specs passed! XX:XX - - - - -
|
||||
|
||||
|
||||
───────────────────────────────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
Recorded Run: https://dashboard.cypress.io/projects/cjvoj7/runs/12
|
||||
|
||||
|
||||
`
|
||||
|
||||
@@ -721,9 +721,13 @@ const createRunAndRecordSpecs = (options = {}) => {
|
||||
const onTestsReceived = (async (runnables, cb) => {
|
||||
// we failed createInstance earlier, nothing to do
|
||||
if (!instanceId) {
|
||||
return
|
||||
return cb()
|
||||
}
|
||||
|
||||
// runnables will be null when there' no tests
|
||||
// this also means runtimeConfig will be missing
|
||||
runnables = runnables || {}
|
||||
|
||||
const r = testsUtils.flattenSuiteIntoRunnables(runnables)
|
||||
const runtimeConfig = runnables.runtimeConfig
|
||||
const resolvedRuntimeConfig = Config.getResolvedRuntimeConfig(config, runtimeConfig)
|
||||
|
||||
@@ -9,6 +9,11 @@ export const flattenSuiteIntoRunnables = (suite, tests = [], hooks = []) => {
|
||||
)
|
||||
}
|
||||
|
||||
// if we dont have a suite, return early
|
||||
if (!suite || !suite.suites) {
|
||||
return [tests, hooks]
|
||||
}
|
||||
|
||||
tests = tests.concat(suite.tests)
|
||||
hooks = hooks.concat(suite.hooks)
|
||||
|
||||
|
||||
@@ -406,6 +406,36 @@ describe('e2e record', () => {
|
||||
})
|
||||
})
|
||||
|
||||
context('empty specs', () => {
|
||||
setupStubbedServer(createRoutes())
|
||||
|
||||
// https://github.com/cypress-io/cypress/issues/15512
|
||||
it('succeeds when empty spec file', async function () {
|
||||
await e2e.exec(this, {
|
||||
key: 'f858a2bc-b469-4e48-be67-0876339ee7e1',
|
||||
record: true,
|
||||
spec: 'empty_suite.spec.js,empty.spec.js',
|
||||
snapshot: true,
|
||||
expectedExitCode: 0,
|
||||
})
|
||||
|
||||
expect(getRequestUrls()).deep.eq([
|
||||
'POST /runs',
|
||||
`POST /runs/${runId}/instances`,
|
||||
`POST /instances/${instanceId}/tests`,
|
||||
`POST /instances/${instanceId}/results`,
|
||||
`PUT /instances/${instanceId}/stdout`,
|
||||
|
||||
`POST /runs/${runId}/instances`,
|
||||
`POST /instances/${instanceId}/tests`,
|
||||
`POST /instances/${instanceId}/results`,
|
||||
`PUT /instances/${instanceId}/stdout`,
|
||||
|
||||
`POST /runs/${runId}/instances`,
|
||||
])
|
||||
})
|
||||
})
|
||||
|
||||
context('projectId', () => {
|
||||
e2e.setup()
|
||||
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
console.log('no tests!')
|
||||
@@ -0,0 +1,4 @@
|
||||
console.log('no tests!')
|
||||
|
||||
describe('suite', () => {
|
||||
})
|
||||
Reference in New Issue
Block a user