Skip to content

Commit 68f63fe

Browse files
Merge branch 'develop' into remove-redundant-test-binary-jobs
2 parents 90d2157 + 02cc29a commit 68f63fe

File tree

280 files changed

+14429
-2579
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

280 files changed

+14429
-2579
lines changed

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
* text=auto
22

33
*.json text eol=lf
4+
5+
packages/errors/__snapshot-html__/** linguist-generated=true

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ packages/config/lib/*.js
1818

1919
# from data-context, compiled .js files
2020
packages/data-context/src/**/*.js
21+
packages/errors/src/**/*.js
22+
packages/errors/test/**/*.js
2123

2224
# from desktop-gui
2325
packages/desktop-gui/cypress/videos
@@ -68,6 +70,7 @@ packages/socket/lib/*.js
6870

6971
# from system-tests
7072
system-tests/.projects
73+
system-tests/.http-mitm-proxy
7174
system-tests/fixtures/large-img
7275

7376
# from npm/react
@@ -83,6 +86,11 @@ system-tests/fixtures/large-img
8386
# from runner-ct
8487
/packages/runner-ct/cypress/screenshots
8588

89+
# from errors
90+
/packages/errors/__snapshot-images__
91+
/packages/errors/__snapshot-md__
92+
/packages/errors/__snapshot-html-local__
93+
8694
# graphql, auto-generated
8795
/packages/launchpad/src/generated
8896
/packages/app/src/generated

.vscode/settings.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,6 @@
3636
"i18n-ally.keystyle": "nested",
3737

3838
// Volar is the main extension that powers Vue's language features.
39-
"volar.autoCompleteRefs": false,
40-
"volar.takeOverMode.enabled": true
39+
// "volar.autoCompleteRefs": false,
40+
// "volar.takeOverMode.enabled": true
4141
}

browser-versions.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"chrome:beta": "98.0.4758.80",
2+
"chrome:beta": "99.0.4844.27",
33
"chrome:stable": "98.0.4758.80"
44
}

circle.yml

Lines changed: 8 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ executors:
8989
# https://github.com/CircleCI-Public/windows-orb/blob/master/src/executors/default.yml
9090
# https://circleci.com/docs/2.0/hello-world-windows/#software-pre-installed-in-the-windows-image
9191
windows: &windows-executor
92-
machine:
92+
machine:
9393
image: windows-server-2019-vs2019:stable
9494
shell: bash.exe -eo pipefail
9595
resource_class: windows.medium
@@ -151,7 +151,7 @@ commands:
151151
- cypress
152152
- .ssh
153153
- node_modules # contains the npm i -g modules
154-
154+
155155
install_cache_helpers_dependencies:
156156
steps:
157157
- run:
@@ -987,6 +987,7 @@ jobs:
987987
- run:
988988
name: Linting 🧹
989989
command: |
990+
yarn clean
990991
git clean -df
991992
yarn lint
992993
- run:
@@ -1075,12 +1076,14 @@ jobs:
10751076
# run unit tests from each individual package
10761077
- run: yarn test
10771078
- verify-mocha-results:
1078-
expectedResultCount: 9
1079+
expectedResultCount: 10
10791080
- store_test_results:
10801081
path: /tmp/cypress
10811082
# CLI tests generate HTML files with sample CLI command output
10821083
- store_artifacts:
10831084
path: cli/test/html
1085+
- store_artifacts:
1086+
path: packages/errors/__snapshot-images__
10841087
- store-npm-logs
10851088

10861089
unit-tests-release:
@@ -1913,13 +1916,6 @@ jobs:
19131916
repo: cypress-example-kitchensink
19141917
browser: "electron"
19151918

1916-
test-binary-against-awesome-typescript-loader:
1917-
<<: *defaults
1918-
steps:
1919-
- test-binary-against-repo:
1920-
repo: cypress-test-awesome-typescript-loader
1921-
browser: "electron"
1922-
19231919
test-binary-against-kitchensink-firefox:
19241920
<<: *defaults
19251921
resource_class: medium
@@ -2212,26 +2208,6 @@ linux-workflow: &linux-workflow
22122208
- test-binary-against-kitchensink:
22132209
requires:
22142210
- create-build-artifacts
2215-
# when working on a feature or a fix,
2216-
# you are probably working in a branch
2217-
# and you want to run a specific PR in the cypress-example-recipes
2218-
# against this branch. This workflow job includes
2219-
# the job but only when it runs on specific branch
2220-
# DO NOT DELETE THIS JOB BEFORE MERGING TO DEVELOP
2221-
# on "develop" this branch will be ignored anyway
2222-
# and someone else might use this job definition for another
2223-
# feature branch and would just update the branch filter
2224-
# - test-binary-against-recipe-pull-request:
2225-
# name: Test cypress run parsing
2226-
# filters:
2227-
# branches:
2228-
# only:
2229-
# - cli-to-module-api-7760
2230-
# requires:
2231-
# - create-build-artifacts
2232-
- test-binary-against-awesome-typescript-loader:
2233-
requires:
2234-
- create-build-artifacts
22352211
- test-binary-and-npm-against-other-projects:
22362212
context: test-runner:trigger-test-jobs
22372213
<<: *mainBuildFilters
@@ -2346,14 +2322,14 @@ windows-workflow: &windows-workflow
23462322
executor: windows
23472323
requires:
23482324
- windows-build
2349-
2325+
23502326
- unit-tests:
23512327
name: windows-unit-tests
23522328
executor: windows
23532329
resource_class: windows.medium
23542330
requires:
23552331
- windows-build
2356-
2332+
23572333
- create-build-artifacts:
23582334
name: windows-create-build-artifacts
23592335
executor: windows

guides/error-handling.md

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
## Error Handling in Cypress
2+
3+
Clear, consistent, errors are one of the important parts of the Cypress experience. When something goes wrong, there should be clear, actionable feedback for the user about exactly *what* went wrong, *where* it went wrong, and next steps on how to fix.
4+
5+
### @packages/errors
6+
7+
All error related logic for the server should be added to `@packages/errors`. This logic has been separated out from the `@packages/server` to enable strict type checking & use in other packages we have added in the `10.0-release` branch.
8+
9+
Summary of the Errors package:
10+
11+
- `errors.ts`: A key/value mapping of known errors to functions returning "ErrorTemplates", described below, also includes/re-exports several helper utilities:
12+
- `get` / `getError`: builds & retrieves the error as a `CypressError`, should be the main way we retrieve errors throughout Cypress. Aliased as `errors.get` for existing use in the server package
13+
- `throw` / `throwErr`: Get & throw the error, so we can spy/stub it in a test. Aliased as `errors.throw` for existing use in the server package
14+
- `logWarning`: Logs the error as a warning to the console, aliased as `errors.log` for existing use in the server package
15+
- `errTemplate.ts`: Tagged template literal formatting the error as described below
16+
- `stackUtils.ts`: Utilities for working with a stack trace, extended by the driver package
17+
18+
### errTemplate
19+
20+
The `errTemplate` is a tagged template literal. It allows us to maintain consistent behavior & formatting in our error messages, when we see a variable, we format it depending on the target environment.
21+
22+
The error message returns a message that defaults to being formatted for the terminal, and has a `forBrowser` method which returns the error message where the variables are wrapped in backticks '`' for Markdown display in the browser.
23+
24+
Return Value of `errTemplate` (`ErrTemplateResult`):
25+
26+
```ts
27+
{
28+
// Will always exist, this is the terminal-formatted error message
29+
message: string,
30+
// Will always exist, this is the browser-formatted error message
31+
messageMarkdown: string,
32+
details?: string, // Exists if there is `details()` call in the errTemplate
33+
originalError?: ErrorLike // Exists if an error was passed into the `details()`
34+
}
35+
```
36+
37+
#### Example:
38+
39+
```ts
40+
CANNOT_TRASH_ASSETS: (arg1: string) => {
41+
return errTemplate`\
42+
Warning: We failed to trash the existing run results.
43+
44+
This error will not alter the exit code.
45+
46+
${details(arg1)}`
47+
},
48+
```
49+
50+
In this case, `arg1` will be highlighted in yellow when printed to the terminal.
51+
52+
53+
```ts
54+
PLUGINS_FILE_ERROR: (arg1: string, arg2: Error) => {
55+
return errTemplate`\
56+
The plugins file is missing or invalid.
57+
58+
Your \`pluginsFile\` is set to ${arg1}, but either the file is missing, it contains a syntax error, or threw an error when required. The \`pluginsFile\` must be a \`.js\`, \`.ts\`, or \`.coffee\` file.
59+
60+
Or you might have renamed the extension of your \`pluginsFile\`. If that's the case, restart the test runner.
61+
62+
Please fix this, or set \`pluginsFile\` to \`false\` if a plugins file is not necessary for your project.
63+
64+
${details(arg2)}
65+
`
66+
},
67+
```
68+
69+
`arg1` will be highlighted in `blue` for the terminal, and wrapped in backticks when called with `forBrowser`. Details will be printed in `yellow` as a stack trace when printed to the terminal, or shown as a stack-trace in the browser.
70+
71+
### Error Wrapping
72+
73+
Any time we know about an edge case that is an error, we should define an error in `errors.ts`. This error should be retrieved by `getError`, which converts it to a `CypressError`.
74+
75+
The `CypressError` is an `Error` containing the message returned from the `errTemplate`. The `stack` is set to that of the `originalError` if it exists (i.e. the error object passed into `details`), otherwise it's the `stack` from where the `getError` / `throwError` is called.
76+
77+
78+
The `CypressError` has an `isCypressErr` prop which we use as a duck-type guard against exiting the process when logging exceptions. It also maintains a reference to the `originalError` if it exists.
79+
80+
### Child-Process Errors
81+
82+
All errors that occur in a child process spawned by Cypress should be sent over the `ipc` bridge using `util.serializeError`.
83+
84+
This ensures the `name`, `message`, `stack`, and any other relevant details are preserved and can be handled by the standard process of Cypress' error standardization / wrapping.
85+

package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,17 @@
1717
"bump": "node ./scripts/binary.js bump",
1818
"check-node-version": "node scripts/check-node-version.js",
1919
"check-terminal": "node scripts/check-terminal.js",
20-
"clean": "lerna run clean --parallel --no-bail",
20+
"clean": "lerna run clean --parallel --no-bail || echo 'ok, errors while cleaning'",
2121
"clean-deps": "find . -depth -name node_modules -type d -exec rm -rf {} \\;",
2222
"clean-untracked-files": "git clean -d -f",
2323
"precypress:open": "yarn ensure-deps",
2424
"cypress:open": "cypress open --dev --global",
25+
"cypress:open:ct": "cypress open-ct --dev --global",
2526
"precypress:open:debug": "yarn ensure-deps",
2627
"cypress:open:debug": "node ./scripts/debug.js cypress:open",
2728
"precypress:run": "yarn ensure-deps",
2829
"cypress:run": "cypress run --dev",
30+
"cypress:run:ct": "cypress run-ct --dev",
2931
"precypress:run:debug": "yarn ensure-deps",
3032
"cypress:run:debug": "node ./scripts/debug.js cypress:run",
3133
"cypress:verify": "cypress verify --dev",
@@ -46,7 +48,7 @@
4648
"stop-only": "npx stop-only --skip .cy,.publish,.projects,node_modules,dist,dist-test,fixtures,lib,bower_components,src,__snapshots__ --exclude e2e.ts,cypress-tests.ts,*only_spec.js",
4749
"stop-only-all": "yarn stop-only --folder packages",
4850
"pretest": "yarn ensure-deps",
49-
"test": "yarn lerna exec yarn test --scope cypress --scope \"'@packages/{config,electron,extension,https-proxy,launcher,net-stubbing,network,proxy,rewriter,runner,runner-shared,socket}'\"",
51+
"test": "yarn lerna exec yarn test --scope cypress --scope \"'@packages/{config,errors,electron,extension,https-proxy,launcher,net-stubbing,network,proxy,rewriter,runner,runner-shared,socket}'\"",
5052
"test-debug": "lerna exec yarn test-debug --ignore \"'@packages/{desktop-gui,driver,root,static,web-config}'\"",
5153
"pretest-e2e": "yarn ensure-deps",
5254
"test-integration": "lerna exec yarn test-integration --ignore \"'@packages/{desktop-gui,driver,root,static,web-config}'\"",
@@ -103,7 +105,6 @@
103105
"@types/sinon-chai": "3.2.3",
104106
"@typescript-eslint/eslint-plugin": "4.18.0",
105107
"@typescript-eslint/parser": "4.18.0",
106-
"ansi-styles": "3.2.1",
107108
"arg": "4.1.2",
108109
"ascii-table": "0.0.9",
109110
"aws-sdk": "2.814.0",
@@ -181,7 +182,7 @@
181182
"snap-shot-it": "7.9.3",
182183
"start-server-and-test": "1.10.8",
183184
"stop-only": "3.0.1",
184-
"strip-ansi": "4.0.0",
185+
"strip-ansi": "6.0.0",
185186
"term-to-html": "1.2.0",
186187
"terminal-banner": "1.1.0",
187188
"through": "2.3.8",

packages/config/__snapshots__/index_spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ exports['src/index .getDefaultValues returns list of public config keys 1'] = {
3434
"ignoreTestFiles": "*.hot-update.js",
3535
"includeShadowDom": false,
3636
"integrationFolder": "cypress/integration",
37-
"isInteractive": true,
3837
"keystrokeDelay": 0,
3938
"modifyObstructiveCode": true,
4039
"numTestsKeptInMemory": 50,
@@ -77,6 +76,7 @@ exports['src/index .getDefaultValues returns list of public config keys 1'] = {
7776
"configFile": "cypress.json",
7877
"devServerPublicPathRoute": "/__cypress/src",
7978
"hosts": null,
79+
"isInteractive": true,
8080
"isTextTerminal": false,
8181
"morgan": true,
8282
"namespace": "__cypress",

0 commit comments

Comments
 (0)