Skip to content

Commit f6b747a

Browse files
fix: include project folder when reporting no specs found (#14810)
Co-authored-by: Jennifer Shehane <jennifer@cypress.io>
1 parent 57e9c78 commit f6b747a

File tree

5 files changed

+51
-24
lines changed

5 files changed

+51
-24
lines changed

packages/server/__snapshots__/5_specs_spec.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,8 @@ We searched for any files matching this glob pattern:
1414
1515
cypress/integration/cypress/integration/**notfound**
1616
17+
Relative to the project root folder:
18+
19+
/foo/bar/.projects/e2e
20+
1721
`

packages/server/__snapshots__/7_record_spec.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -799,6 +799,10 @@ We searched for any files matching this glob pattern:
799799
800800
cypress/integration/notfound/**
801801
802+
Relative to the project root folder:
803+
804+
/foo/bar/.projects/e2e
805+
802806
`
803807

804808
exports['e2e record recordKey warns but does not exit when is forked pr 1'] = `

packages/server/lib/errors.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,7 @@ const getMsgByType = function (type, arg1 = {}, arg2, arg3) {
497497
Error writing to: ${chalk.blue(filePath)}
498498
499499
${chalk.yellow(err)}`
500+
500501
case 'NO_SPECS_FOUND':
501502
// no glob provided, searched all specs
502503
if (!arg2) {
@@ -513,7 +514,11 @@ const getMsgByType = function (type, arg1 = {}, arg2, arg3) {
513514
514515
We searched for any files matching this glob pattern:
515516
516-
${chalk.blue(arg2)}`
517+
${chalk.blue(arg2)}
518+
519+
Relative to the project root folder:
520+
521+
${chalk.blue(arg1)}`
517522

518523
case 'RENDERER_CRASHED':
519524
return stripIndent`\

packages/server/lib/modes/run.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1476,7 +1476,13 @@ module.exports = {
14761476
}
14771477

14781478
if (!specs.length) {
1479-
errors.throw('NO_SPECS_FOUND', config.integrationFolder, specPattern)
1479+
// did we use the spec pattern?
1480+
if (specPattern) {
1481+
errors.throw('NO_SPECS_FOUND', projectRoot, specPattern)
1482+
} else {
1483+
// else we looked in the integration folder
1484+
errors.throw('NO_SPECS_FOUND', config.integrationFolder, specPattern)
1485+
}
14801486
}
14811487

14821488
if (browser.family === 'chromium') {

packages/server/test/integration/cypress_spec.js

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -854,32 +854,40 @@ describe('lib/cypress', () => {
854854
})
855855
})
856856

857-
it('logs error and exits when spec file was specified and does not exist', function () {
858-
return cypress.start([`--run-project=${this.todosPath}`, '--spec=path/to/spec'])
859-
.then(() => {
860-
this.expectExitWithErr('NO_SPECS_FOUND', 'path/to/spec')
861-
this.expectExitWithErr('NO_SPECS_FOUND', 'We searched for any files matching this glob pattern:')
857+
describe('no specs found', function () {
858+
it('logs error and exits when spec file was specified and does not exist', function () {
859+
return cypress.start([`--run-project=${this.todosPath}`, '--spec=path/to/spec'])
860+
.then(() => {
861+
// includes the search spec
862+
this.expectExitWithErr('NO_SPECS_FOUND', 'path/to/spec')
863+
this.expectExitWithErr('NO_SPECS_FOUND', 'We searched for any files matching this glob pattern:')
864+
// includes the project path
865+
this.expectExitWithErr('NO_SPECS_FOUND', this.todosPath)
866+
})
862867
})
863-
})
864868

865-
it('logs error and exits when spec absolute file was specified and does not exist', function () {
866-
return cypress.start([
867-
`--run-project=${this.todosPath}`,
868-
`--spec=${this.todosPath}/tests/path/to/spec`,
869-
])
870-
.then(() => {
871-
this.expectExitWithErr('NO_SPECS_FOUND', 'tests/path/to/spec')
869+
it('logs error and exits when spec absolute file was specified and does not exist', function () {
870+
return cypress.start([
871+
`--run-project=${this.todosPath}`,
872+
`--spec=${this.todosPath}/tests/path/to/spec`,
873+
])
874+
.then(() => {
875+
// includes path to the spec
876+
this.expectExitWithErr('NO_SPECS_FOUND', 'tests/path/to/spec')
877+
// includes folder name
878+
this.expectExitWithErr('NO_SPECS_FOUND', this.todosPath)
879+
})
872880
})
873-
})
874881

875-
it('logs error and exits when no specs were found at all', function () {
876-
return cypress.start([
877-
`--run-project=${this.todosPath}`,
878-
'--config=integrationFolder=cypress/specs',
879-
])
880-
.then(() => {
881-
this.expectExitWithErr('NO_SPECS_FOUND', 'We searched for any files inside of this folder:')
882-
this.expectExitWithErr('NO_SPECS_FOUND', 'cypress/specs')
882+
it('logs error and exits when no specs were found at all', function () {
883+
return cypress.start([
884+
`--run-project=${this.todosPath}`,
885+
'--config=integrationFolder=cypress/specs',
886+
])
887+
.then(() => {
888+
this.expectExitWithErr('NO_SPECS_FOUND', 'We searched for any files inside of this folder:')
889+
this.expectExitWithErr('NO_SPECS_FOUND', 'cypress/specs')
890+
})
883891
})
884892
})
885893

0 commit comments

Comments
 (0)