Skip to content

Commit c1205a7

Browse files
committed
expanded + enhanced README
1 parent 40f6342 commit c1205a7

File tree

1 file changed

+36
-1
lines changed

1 file changed

+36
-1
lines changed

system-tests/README.md

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,44 @@ To keep the browser open after a spec run (for easier debugging and iterating on
2222
yarn test test/go_spec.js --browser chrome --no-exit
2323
```
2424

25+
To debug the Cypress process under test, you can pass `--cypress-inspect-brk`:
26+
27+
```sh
28+
yarn test test/go_spec.js --browser chrome --no-exit
29+
```
30+
2531
## Developing tests
2632

27-
TODO
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+
35+
There are two parts to a system test:
36+
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.
39+
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+
42+
```ts
43+
// ./test/my-new-project.spec.ts
44+
import systemTests from '../lib/system-tests'
45+
import Fixtures from '../lib/fixtures'
46+
47+
describe('my new project', () => {
48+
// scaffold projects
49+
systemTests.setup()
50+
51+
systemTests.it('fails as expected', {
52+
project: Fixtures.projectPath('my-new-project'),
53+
snapshot: true,
54+
spec: '*',
55+
expectedExitCode: 2
56+
})
57+
})
58+
```
59+
60+
From here, you could
61+
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.
2863

2964
## Updating snaphots
3065

0 commit comments

Comments
 (0)