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: DEVELOPMENT.md
+56Lines changed: 56 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,3 +8,59 @@ In order to create a new release you have two options:
8
8
9
9
1. Locally run `npm run release` and follow the interactive CLI
10
10
2. Manually trigger the GitHub Action `release` workflow specifyin the type of release you want to create
11
+
12
+
## Tests
13
+
14
+
To run the tests, you can use the following command:
15
+
16
+
```sh
17
+
npm test
18
+
```
19
+
20
+
This will run both `browser` and `node` tests.
21
+
22
+
### Browser
23
+
24
+
Browser tests use [`wtr`](https://modern-web.dev/docs/test-runner/overview/) as the test runner. To build browser bundle using [esbuild](https://esbuild.github.io/) and run browser tests, you can use the following command:
25
+
26
+
```sh
27
+
npm run test:browser
28
+
```
29
+
30
+
The configuration file is [web-test-runner.config.msj](./web-test-runner.config.mjs). It starts a local broker using [aedes-cli](https://github.com/moscajs/aedes-cli) with `ws` and `wss` support and then runs the tests in 3 different browsers: `chrome`, `firefox` and `safari`.
31
+
32
+
The tests are located in the `test/browser` directory and there are also tests for service workers in the `test/browser/worker.js` directory.
33
+
34
+
When developing/debugging tests it's useful to run the tests in a single browser, for example:
35
+
36
+
```sh
37
+
npx wtr --manual --open
38
+
```
39
+
40
+
This will open the browser on `localhost:8001` and lets you choose the test to run by clicking on the link with the test name. By opening the DevTools you will be able to see the tests output and put debugger in both worker and main tests files.
41
+
42
+
Be aware that tests will use the bundled version of the library, so you need to run `npm run build` before running the tests. If you need to debug issues in the code it could be useful to enable source maps when building, in order to do this just set `sourcemap: true` in [esbuild.js](./esbuild.js) file and run `npm run build`.
43
+
44
+
### Node
45
+
46
+
For NodeJS tests we use the NodeJS [Test Runner](https://nodejs.org/api/test.html). To run the tests, you can use the following command:
47
+
48
+
```sh
49
+
npm run test:node
50
+
```
51
+
52
+
The tests are located in the `test` directory. The entrypoint of tests is `runTests.ts` file. It is used to filter the tests to run, set concurrency and create a nice looking tests summary (see reason [here](https://github.com/nodejs/help/issues/3902#issuecomment-1726033310))
53
+
54
+
When developing/debugging tests it's useful to run the tests for a single file/test, for example:
0 commit comments