Skip to content

Commit b81c5a0

Browse files
chore: convert tests in @packages/errors from mocha to vitest (#32572)
* start vitest convertion and convert errors spec to vitest * chore: convert errTemplate to vitest * convert stripIndent to vitest * convert the visualsnapshoterrors spec to vitest * chore: clean up errors package, update guide, and move snapshots * move tests out of unit test directory as most tests are integration tests * add to esm checklist and update workflow * clean build and rebuild after test due to CI having built files * Chore: fix bad test assertion in error spec * Update guides/esm-migration.md Co-authored-by: Bill Glesias <[email protected]> * chore: remove unused FIREFOX_CDP_FAILED_TO_CONNECT error as it is no longer used and likely missed with the CDP removal for Firefox * chore: fix missed imports * remove system test code to check for CDP error in firefox --------- Co-authored-by: Jennifer Shehane <[email protected]>
1 parent 236c88e commit b81c5a0

File tree

332 files changed

+1360
-7600
lines changed

Some content is hidden

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

332 files changed

+1360
-7600
lines changed

.circleci/workflows.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3486,7 +3486,7 @@ jobs:
34863486
yarn lerna run types
34873487
name: Test types
34883488
- sanitize-verify-and-store-mocha-results:
3489-
expectedResultCount: 17
3489+
expectedResultCount: 16
34903490
working_directory: ~/cypress
34913491
v8-integration-tests:
34923492
environment:
-281 KB
Binary file not shown.
91.5 KB
Loading

guides/error-handling.md

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,23 @@ All error related logic for the server should be added to `@packages/errors`.
88

99
### Errors Development Workflow
1010

11-
Adding and editing errors is best done with the help of the Error Comparison tool.
11+
Adding and editing errors is best done with the help of an ANSI Comparison tool. Cursor/VSCode offer the [vscode-ansi](https://marketplace.cursorapi.com/items/?itemName=iliazeus.vscode-ansi) comparison tool.
1212

13-
Start off by launching the Error Comparison tool from `packages/errors` via `yarn comparison`. This will launch a mini-webapp at http://localhost:5555.
14-
15-
The Error Comparison app has three pages: Ansi Compare, Ansi Base List, and Markdown.
16-
17-
1. Ansi Compare - Used to compare and accept changes made during development
18-
2. Ansi Base List - Used to preview errors as they will be rendered to users in the Terminal.
19-
3. Markdown - Used to preview errors as they will be rendered to users within the App, Launchpad, and Reporter.
13+
Errors can be compared directly in your code error. Comparing old vs new errors can be done via comparing the git diff or the snapshot diff.
2014

2115
#### Editing or Adding New Errors and Updating Snapshots
2216

23-
<img src="./error-handling-accept-snapshot.png" width="1200" />
17+
<img src="./error-handling-snapshot-compare.png" width="1200"/>
2418

2519
1. Add (or update) errors in `packages/errors/src/errors.ts`
26-
2. Add test cases to `visualSnapshotErrors_spec.ts`
27-
3. Run `yarn test` in the `packages/errors` directory
28-
4. Run `yarn comparison` in the `packages/errors` directory
29-
5. Open http://localhost:5555/
30-
6. Search for the error you're working on by the error key. (e.g. `AUTOMATION_SERVER_DISCONNECTED`)
31-
7. Click "Looks Good" if it looks good.
32-
8. To make edits, re-run the `yarn test` command and do a full refresh of the webapp.
33-
9. Run `yarn test` after updating the snapshot to validate the changes were applied.
34-
10. Commit the files changed in `__snapshot-html__`
20+
2. Add test cases to `visualSnapshotErrors.spec.ts`.
21+
3. Run `yarn test` in the `packages/errors` directory.
22+
4. See the `.ansi` file generated/edited for your added test case. The file should be named by the error key. (e.g. `AUTOMATION_SERVER_DISCONNECTED`).
23+
5. click the "Open Preview to the Side" icon in the top right portion of your code editor.
24+
6. Verify the changes expected.
25+
7. To make edits, re-run the `yarn test -u` command. `-u` will update the test snapshots.
26+
8. Run `yarn test` after updating the snapshot to validate the changes were applied.
27+
9. Commit the files changed in `./test/__snapshots__`.
3528

3629
### Technical Overview
3730

guides/esm-migration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@
9090
- [ ] packages/data-context
9191
- [x] packages/driver ✅ **COMPLETED**
9292
- [x] packages/electron ✅ **COMPLETED**
93-
- [ ] packages/error
93+
- [x] packages/error**COMPLETED**
9494
- [ ] packages/extension
9595
- [ ] packages/https-proxy
9696
- [x] packages/electron ✅ **COMPLETED**

packages/data-context/schemas/schema.graphql

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1188,7 +1188,6 @@ enum ErrorTypeEnum {
11881188
EXPERIMENTAL_SKIP_DOMAIN_INJECTION_REMOVED
11891189
EXPERIMENTAL_STUDIO_E2E_ONLY
11901190
EXTENSION_NOT_LOADED
1191-
FIREFOX_CDP_FAILED_TO_CONNECT
11921191
FIREFOX_COULD_NOT_CONNECT
11931192
FIREFOX_GECKODRIVER_FAILURE
11941193
FIXTURE_NOT_FOUND

packages/errors/.mocharc.js

Lines changed: 0 additions & 11 deletions
This file was deleted.

packages/errors/__snapshot-html__/AUTOMATION_SERVER_DISCONNECTED.html

Lines changed: 0 additions & 38 deletions
This file was deleted.

packages/errors/__snapshot-html__/BAD_POLICY_WARNING.html

Lines changed: 0 additions & 45 deletions
This file was deleted.

packages/errors/__snapshot-html__/BAD_POLICY_WARNING_TOOLTIP.html

Lines changed: 0 additions & 38 deletions
This file was deleted.

0 commit comments

Comments
 (0)