blob: 353a47b1f2ac4d597fba7e78a18a326b45011775 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
## Build the Docker image
docker build -t btroops .
## Install packages
./npm install
## Start the dev server
./npm run start
Visit `localhost:8080` to view.
## Run integration tests
./npm run test:integ
### Debugging an integration test
1. Put `debugger` in whatever test you want to debug.
2. Add `only` to the test's `it` function call.
From `it(...` to `it.only(...`.
3. Then run `./npm run test:integ:debug` to start start the debugger.
```
> test:integ:debug
> NODE_INSPECT_RESUME_ON_START=1 node inspect ./node_modules/jest/bin/jest.js --config jest.config.integ.cjs --runInBand test/integration/page.test.js
< Debugger listening on ws://127.0.0.1:9229/7150f5fc-339a-4171-af42-b8902d0d3e31
< For help, see: https://nodejs.org/en/docs/inspector
<
connecting to 127.0.0.1:9229 ... ok
< Debugger attached.
<
< Jest config file read.
<
<
< Spawning server process...
<
< Test server running at http://localhost:3005
< Build completed in 11ms
<
<
break in test/integration/page.test.js:31
29 counter = await driver.findElement(By.css(selector), svg);
30 await counter.click();
>31 debugger;
32 expect(await counter.getAttribute('class')).toEqual(expect.stringContaining('selected'));
33 });
debug>
```
4. To run the test again without having to quit the debugger, use `c` to continue past the breakpoint and then `r` to restart.
```
debug> c
...
<
< Stopping server.
<
< Waiting for the debugger to disconnect...
<
```
```
debug> r
< Debugger listening on ws://127.0.0.1:9229/1cda953e-c9ae-41d8-9d4a-e41a567e0826
< For help, see: https://nodejs.org/en/docs/inspector
<
connecting to 127.0.0.1:9229 ... ok
< Debugger attached.
<
< Jest config file read.
<
<
< Spawning server process...
<
< Test server running at http://localhost:3005
< Build completed in 11ms
<
<
break in test/integration/page.test.js:31
29 counter = await driver.findElement(By.css(selector), svg);
30 await counter.click();
>31 debugger;
32 expect(await counter.getAttribute('class')).toEqual(expect.stringContaining('selected'));
33 });
debug>
```
### References
https://nodejs.org/en/learn/getting-started/debugging
https://nodejs.org/api/debugger.html
|