Skip to content

Commit 411fe2a

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

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

system-tests/README.md

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,41 @@ 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+
import systemTests from '../lib/system-tests'
44+
import Fixtures from '../lib/fixtures'
45+
46+
describe('my new project', () => {
47+
// scaffold projects
48+
systemTests.setup()
49+
50+
systemTests.it('fails as expected', {
51+
project: Fixtures.projectPath('my-new-project'),
52+
snapshot: true,
53+
spec: '*',
54+
expectedExitCode: 2
55+
})
56+
})
57+
```
58+
59+
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.
2860

2961
## Updating snaphots
3062

0 commit comments

Comments
 (0)