@@ -94,6 +94,14 @@ attribute.
94
94
rebuilds the project. It does also watch all changes made to the built project
95
95
and restarts the code whenever changes are detected. This enables a quick
96
96
feedback loop.
97
+ - ` yarn debug ` -> Starts the app in debugging mode. Waits for a debugger to
98
+ attach. See Debugging below for more info.
99
+ - If you want to restart the debugging process every time you change the code,
100
+ you can use something like `nodemon --watch src --watch test --ext ts,json
101
+ --exec 'yarn debug'` or when debugging tests with ` nodemon --watch src --watch
102
+ test --ext ts,json --exec 'yarn debug: test '`
103
+ - ` yarn debug:test ` -> Starts the test run in debugging mode. Waits for a
104
+ debugger to attach. See Debugging below for more info.
97
105
- ` yarn format ` -> Formats the code using prettier.
98
106
- ` yarn format:check ` -> Checks for formatting errors using prettier. This is
99
107
typically only invoked by the CI/CD pipeline.
@@ -120,39 +128,35 @@ DAP compliant debugger
120
128
121
129
### Debugging Code
122
130
123
- #### Vim
131
+ There are somewhat "different" ways of starting the debugger. Once is by
132
+ starting the app and waiting for a debugger to connect and the other one is
133
+ starting the app initiated by the debugger. I made the experience that the
134
+ former works on any given code base, no matter the amount of transipilation or
135
+ bundling steps and custom steups while the latter does fail in extremely
136
+ customized scenarios. Therefore here only the first one is covered with
137
+ examples.
124
138
125
- - Start the node process with inspect-brk `yarn bundle && node
126
- --enable-source-maps --inspect-brk ./dist/src/index.js` in one terminal.
127
- - Open src/index.ts ` vim ./src/index.ts ` in another terminal.
128
- - Set breakpoint in line 6 (F9 is the default mapping)
129
- - Start vimspector by pressing F5
139
+ #### Vim or Vscode
140
+
141
+ - Run ` yarn debug ` in another terminal
142
+ - Open src/index.ts ` vim ./src/index.ts ` (or code ./src/index.ts) in another terminal.
143
+ - Set breakpoint somewhere in the file at the console log (F9 is the default mapping).
144
+ - Start by pressing F5
130
145
- Press F5 again, should see the console.log output
131
146
- Done🎉
132
147
133
- #### Vscode
134
-
135
- - Open code, set a breakpoint in src/index.ts and just start debugging with F5.
136
-
137
148
### Debugging Tests
138
149
139
- #### Vim
150
+ #### Vim or Vscode
140
151
141
- - Start the node process with inspect-brk `node --enable-source-maps
142
- --inspect-brk --no-lazy ./node_modules/.bin/jest --runInBand .` in one
143
- terminal.
152
+ - Run ` yarn debug:test ` in another terminal
144
153
- Open src/index.ts ` vim ./src/hello.test.ts ` in another terminal.
145
- - Set breakpoint in line 8 (F9 is the default mapping)
146
- - Start vimspector by pressing F5
147
- - You should see the first console log already "testing returnHelloWorld()"
148
- - Press F5 again, should see the second console.log "Done"
154
+ - Set breakpoint in the line of the console log in the test file.
155
+ - Start by pressing F5 (then skip the jest internal file once with F5)
156
+ - Check the terminal where you ran ` yarn debug:test ` , it should not display the console log yet.
157
+ - Press F5 again, should see the console.log output there now.
149
158
- Done🎉
150
159
151
- #### Vscode
152
-
153
- - Open code and set a breakpoint in /src/hello.test.ts.
154
- - Go to the package.json in the 'scripts' sections, click on 'debug' and select 'test'.
155
-
156
160
## Linting
157
161
158
162
This repo has [ eslint] ( https://eslint.org/ ) and
0 commit comments