You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: system-tests/README.md
+26-4Lines changed: 26 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,7 @@ These tests launch the [Cypress server](../packages/server) process for each tes
7
7
8
8
These tests run in CI in Electron, Chrome, and Firefox under the `system-tests` job family.
9
9
10
-
## Running system tests
10
+
## Running System Tests
11
11
12
12
```bash
13
13
yarn test<path/to/test>
@@ -28,14 +28,14 @@ To debug the Cypress process under test, you can pass `--cypress-inspect-brk`:
28
28
yarn test test/go_spec.js --browser chrome --no-exit
29
29
```
30
30
31
-
## Developing tests
31
+
## Developing Tests
32
32
33
33
System tests cover the entire Cypress run, so they are good for testing features that do not fit into a normal integration or unit test. However, they do take more resources to run, so consider carefully if you really *need* to write a system test, or if you could achieve 100% coverage via an integration or unit test instead.
34
34
35
35
There are two parts to a system test:
36
36
37
37
1. A test written using the [`systemTests`](./lib/system-tests) Mocha wrapper that lives in [`./test`](./test), and
38
-
2. A matching Cypress project that lives in the [`./projects`](./projects) directory.
38
+
2. A matching Cypress [test project](#Test-Projects) that lives in the [`./projects`](./projects) directory.
39
39
40
40
For example, if you initialized a new project in `./projects/my-new-project`, and you wanted to assert that 2 tests fail and take a snapshot of the `stdout`, you'd write a test like this:
41
41
@@ -61,10 +61,32 @@ From here, you could run this test with `yarn test my-new-project`.
61
61
62
62
There are many more options available for `systemTests.it` and `systemTests.setup`. You can massage the stdout, do pre-run tasks, set up HTTP/S servers, and more. Explore the typedocs in [`./lib/system-tests`](./lib/system-tests) for more information.
63
63
64
-
## Updating snaphots
64
+
###Updating Snaphots
65
65
66
66
Prepend `SNAPSHOT_UPDATE=1` to any test command. See [`snap-shot-it` instructions](https://github.com/bahmutov/snap-shot-it#advanced-use) for more info.
67
67
68
68
```bash
69
69
SNAPSHOT_UPDATE=1 yarn test go_spec
70
70
```
71
+
72
+
### Test Projects
73
+
74
+
Every folder in [`./projects`](./lib/projects) represents a self-contained Cypress project. When you pass the `project` property to `systemTests.it` or `systemTests.exec`, Cypress launches using this project.
75
+
76
+
If a test project has a `package.json` file, the `systemTests.exec` helper will attempt to install the correct `node_modules` by running `yarn install` against the project. This is cached in CI and locally to speed up test times.
77
+
78
+
`systemTests.exec`*copies* the project directory to a temporary folder outside of the monorepo root. This means that temporary projects will not inherit the `node_modules` from this package or the monorepo. So, you must add the dependencies required for your project in `dependencies` or `devDependencies`.
79
+
80
+
The exception is some commonly used packages that are scaffolded for all projects, like `lodash` and `debug`. You can see the list by looking at `scaffoldCommonNodeModules` in [`./lib/fixtures.ts`](./lib/fixtures.ts) These packages do not need to be added to a test project's `package.json`.
81
+
82
+
You can also set special properties in a test project's `package.json` to influence the helper's behavior when running `yarn`:
83
+
84
+
`package.json` Property Name | Type | Description
85
+
--- | --- | ---
86
+
`_cySkipYarnInstall` | `boolean` | If `true`, skip the automatic `yarn install` for this package, even though it has a `package.json`.
87
+
`_cyYarnV2` | `boolean` | Run the yarn v2-style install command instead of yarn v1-style.
88
+
`_cyRunScripts` | `boolean` | By default, the automatic `yarn install` will not run postinstall scripts. This option, if set, will cause postinstall scripts to run for this project.
89
+
90
+
Run `yarn projects:yarn:install` to run `yarn install` for all projects with a `package.json`.
91
+
92
+
Use the `UPDATE_YARN_LOCK=1` environment variable with `yarn test` or `yarn projects:yarn:install` to allow the `yarn.lock` to be updated and synced back to the monorepo from the temp dir.
0 commit comments