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

feat: show better error message if testing type is not configured #22000

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
7cac284
feat: show better error message if testing type is not configured
estrada9166 Jun 1, 2022
4a335dd
Merge branch 'develop' into alejandro/feat/show-better-error-message-…
estrada9166 Jun 2, 2022
85b8ca1
Add tests
estrada9166 Jun 2, 2022
efa5745
Update tests
estrada9166 Jun 2, 2022
94e414c
Merge branch 'develop' into alejandro/feat/show-better-error-message-…
estrada9166 Jun 2, 2022
165c145
Merge branch 'develop' into alejandro/feat/show-better-error-message-…
estrada9166 Jun 3, 2022
b8ca2d9
Fix some tests
estrada9166 Jun 3, 2022
a059086
Fix some tests
estrada9166 Jun 3, 2022
549a46e
Merge branch 'develop' into alejandro/feat/show-better-error-message-…
estrada9166 Jun 3, 2022
500b6b6
Fix test
estrada9166 Jun 3, 2022
3590c62
Merge branch 'develop' into alejandro/feat/show-better-error-message-…
estrada9166 Jun 6, 2022
4f495a5
Merge branch 'develop' into alejandro/feat/show-better-error-message-…
estrada9166 Jun 6, 2022
2e14988
Merge branch 'develop' into alejandro/feat/show-better-error-message-…
estrada9166 Jun 6, 2022
d6dea78
Fix tests
estrada9166 Jun 6, 2022
ef596d6
Update packages/errors/src/errors.ts
estrada9166 Jun 6, 2022
b089333
Update with code review
estrada9166 Jun 6, 2022
92143d5
Merge branch 'develop' into alejandro/feat/show-better-error-message-…
estrada9166 Jun 6, 2022
8f71591
Fix test
estrada9166 Jun 6, 2022
a35defa
Merge branch 'alejandro/feat/show-better-error-message-if-testingType…
estrada9166 Jun 6, 2022
90070e3
Add on link
estrada9166 Jun 7, 2022
23a3654
Merge branch 'develop' into alejandro/feat/show-better-error-message-…
estrada9166 Jun 7, 2022
dcc70c0
Merge branch 'develop' into alejandro/feat/show-better-error-message-…
estrada9166 Jun 7, 2022
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
4 changes: 2 additions & 2 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -835,7 +835,7 @@ commands:
command: |
if [[ -f cypress.json ]]; then
rm -rf cypress.json
echo 'module.exports = {}' > cypress.config.js
echo 'module.exports = { e2e: {} }' > cypress.config.js
fi
- run:
name: Rename support file
Expand Down Expand Up @@ -2211,7 +2211,7 @@ jobs:
CYPRESS_INTERNAL_FORCE_SCAFFOLD: "1"
command: |
rm -rf cypress.json
echo 'module.exports = {}' > cypress.config.js
echo 'module.exports = { e2e: {} }' > cypress.config.js
- run:
name: Rename support file
working_directory: test-binary
Expand Down
4 changes: 4 additions & 0 deletions packages/data-context/src/data/ProjectLifecycleManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,10 @@ export class ProjectLifecycleManager {
return
}

if (this.ctx.isRunMode && this.loadedConfigFile && !this.isTestingTypeConfigured(testingType)) {
return this.ctx.onError(getError('TESTING_TYPE_NOT_CONFIGURED', testingType))
}

if (this.ctx.isRunMode || (this.isTestingTypeConfigured(testingType) && !(this.ctx.coreData.forceReconfigureProject && this.ctx.coreData.forceReconfigureProject[testingType]))) {
this._configManager.loadTestingType()
}
Expand Down
43 changes: 43 additions & 0 deletions packages/errors/__snapshot-html__/TESTING_TYPE_NOT_CONFIGURED.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions packages/errors/src/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1551,6 +1551,16 @@ export const AllCypressErrors = {
the devServer config as a ${fmt.highlight(devServerConfigFile)} option.
`
},

TESTING_TYPE_NOT_CONFIGURED: (testingType: TestingType) => {
return errTemplate`
The testing type selected (${fmt.highlight(testingType)}) is not configured in your config file.

Please run ‘cypress open’ and choose your testing type to automatically update your configuration file.

https://on.cypress.io/configuration
`
},
} as const

// eslint-disable-next-line @typescript-eslint/no-unused-vars
Expand Down
5 changes: 5 additions & 0 deletions packages/errors/test/unit/visualSnapshotErrors_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1167,5 +1167,10 @@ describe('visual error templates', () => {
default: ['vite', '/dev/project', ['vite.config.js', 'vite.config.ts']],
}
},
TESTING_TYPE_NOT_CONFIGURED: () => {
return {
default: ['component'],
}
},
})
})
1 change: 1 addition & 0 deletions packages/graphql/schemas/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,7 @@ enum ErrorTypeEnum {
SETUP_NODE_EVENTS_INVALID_EVENT_NAME_ERROR
SETUP_NODE_EVENTS_IS_NOT_FUNCTION
SUPPORT_FILE_NOT_FOUND
TESTING_TYPE_NOT_CONFIGURED
TESTS_DID_NOT_START_FAILED
TESTS_DID_NOT_START_RETRYING
TEST_FILES_RENAMED
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
exports['testing type not configured error on run mode / reports correct exit code when failing attempting to run e2e'] = `
The testing type selected (e2e) is not configured in your config file.

Please run ‘cypress open’ and choose your testing type to automatically update your configuration file.

https://on.cypress.io/configuration


`

exports['testing type not configured error on run mode / reports correct exit code when failing attempting to run component'] = `
The testing type selected (component) is not configured in your config file.

Please run ‘cypress open’ and choose your testing type to automatically update your configuration file.

https://on.cypress.io/configuration


`
4 changes: 3 additions & 1 deletion system-tests/projects/busted-support-file/cypress.config.js
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
module.exports = {}
module.exports = {
e2e: {},
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
module.exports = {
component: {
baseUrl: 'https://foo.com',
devServer: {
framework: 'create-react-app',
bundler: 'webpack',
},
},
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
module.exports = {
component: {
experimentalSessionAndOrigin: true,
devServer: {
framework: 'create-react-app',
bundler: 'webpack',
},
},
}
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
module.exports = {}
module.exports = {
e2e: {},
}
4 changes: 3 additions & 1 deletion system-tests/projects/ts-proj-4-5/cypress.config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { defineConfig } from 'cypress'

export default defineConfig({})
export default defineConfig({
e2e: {},
})
4 changes: 3 additions & 1 deletion system-tests/projects/ts-proj/cypress.config.ts
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
module.exports = {}
module.exports = {
e2e: {},
}
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
module.exports = {}
module.exports = {
e2e: {},
}
2 changes: 2 additions & 0 deletions system-tests/test/cookies_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ describe('e2e cookies', () => {
https: true,
}],
settings: {
e2e: {},
hosts: {
'*.foo.com': '127.0.0.1',
'*.bar.net': '127.0.0.1',
Expand Down Expand Up @@ -339,6 +340,7 @@ describe('cross-origin cookies, set:cookies', () => {
'*.bar.net': '127.0.0.1',
'*.cypress.test': '127.0.0.1',
},
e2e: {},
},

})
Expand Down
1 change: 1 addition & 0 deletions system-tests/test/cy_origin_error_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ describe('e2e cy.origin errors', () => {
onServer,
}],
settings: {
e2e: {},
hosts: {
'*.foobar.com': '127.0.0.1',
},
Expand Down
1 change: 1 addition & 0 deletions system-tests/test/cy_origin_retries_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ describe('e2e cy.origin retries', () => {
hosts: {
'*.foobar.com': '127.0.0.1',
},
e2e: {},
},
})

Expand Down
2 changes: 2 additions & 0 deletions system-tests/test/form_submissions_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ describe('e2e forms', () => {
context('<form> submissions', () => {
systemTests.setup({
settings: {
e2e: {},
env: {
PATH_TO_LARGE_IMAGE: pathToLargeImage,
},
Expand Down Expand Up @@ -149,6 +150,7 @@ describe('e2e forms', () => {
systemTests.it('passes with http on localhost', {
config: {
baseUrl: `http://localhost:${HTTP_PORT}`,
e2e: {},
},
spec: 'form_submission_multipart.cy.js',
snapshot: true,
Expand Down
1 change: 1 addition & 0 deletions system-tests/test/session_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ describe('e2e sessions', () => {
hosts: {
'*.foo.com': '127.0.0.1',
},
e2e: {},
},
})

Expand Down
1 change: 1 addition & 0 deletions system-tests/test/stdout_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ describe('e2e stdout', () => {
'www.apple.com': '127.0.0.1',
'*.cypress.io': '127.0.0.1',
},
e2e: {},
},
})

Expand Down
19 changes: 19 additions & 0 deletions system-tests/test/testing_type_not_configured_error_spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const systemTests = require('../lib/system-tests').default

describe('testing type not configured error on run mode', () => {
systemTests.setup()

systemTests.it('reports correct exit code when failing attempting to run e2e', {
project: 'simple-ct',
testingType: 'e2e',
snapshot: true,
expectedExitCode: 1,
})

systemTests.it('reports correct exit code when failing attempting to run component', {
project: 'e2e',
testingType: 'component',
snapshot: true,
expectedExitCode: 1,
})
})
1 change: 1 addition & 0 deletions system-tests/test/viewport_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ describe('e2e viewport', () => {
settings: {
viewportWidth: 800,
viewportHeight: 600,
e2e: {},
},
})

Expand Down
3 changes: 3 additions & 0 deletions system-tests/test/visit_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ describe('e2e visit', () => {
settings: {
responseTimeout: 500,
pageLoadTimeout: 1000,
e2e: {},
},
servers: {
port: 3434,
Expand Down Expand Up @@ -194,6 +195,7 @@ describe('e2e visit', () => {
systemTests.setup({
settings: {
responseTimeout: 2000,
e2e: {},
},
servers: {
port: 3434,
Expand All @@ -213,6 +215,7 @@ describe('e2e visit', () => {
systemTests.setup({
settings: {
pageLoadTimeout: 1000,
e2e: {},
},
servers: {
port: 3434,
Expand Down
1 change: 1 addition & 0 deletions system-tests/test/web_security_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ describe('e2e web security', () => {
'*.bar.com': '127.0.0.1',
'*.foobar.com': '127.0.0.1',
},
e2e: {},
},
})

Expand Down