Skip to content

Commit d2587ce

Browse files
authored
Replace Karma with Vitest for JavaScript testing (#2197)
* Replace Karma with Vitest to run JS tests * Update JS packages * Allow developers to track JS code coverage
1 parent 5a0c8ce commit d2587ce

File tree

12 files changed

+3675
-2207
lines changed

12 files changed

+3675
-2207
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,7 @@ jobs:
5454

5555
# Test JS
5656
- run: npm run lint --prefix assets
57-
- name: npm run test --prefix assets
58-
run: |
59-
sudo apt-get install xvfb
60-
xvfb-run --auto-servernum npm run test --prefix assets
61-
env:
62-
CI: true
57+
- run: npm run test --prefix assets
6358

6459
# Push updated assets if all good
6560
- name: Push updated assets

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,6 @@ formatters/html/dist/html.js
3434

3535
# Ignore escript when built
3636
/ex_doc
37+
38+
# Ignore coverage directory created by Vitest
39+
assets/coverage/

assets/README.md

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ To work on these assets you need to have [Node.js] and [npm] installed. (npm is
77
Assets are built with [esbuild], which, along with the JavaScript linter and test-runner, is set as a dependency in the assets `package.json` and installed via [npm]:
88

99
```bash
10-
$ npm install --prefix assets
10+
npm install --prefix assets
1111
```
1212

1313
## `npm run` scripts
@@ -17,7 +17,7 @@ The following scripts are available from the root folder of the project.
1717
### `build`
1818

1919
```bash
20-
$ npm run --prefix assets build
20+
npm run --prefix assets build
2121
```
2222

2323
Build a complete production bundle, including JavaScript and CSS.
@@ -27,7 +27,7 @@ Build a complete production bundle, including JavaScript and CSS.
2727
### `build:watch`
2828

2929
```bash
30-
$ npm run --prefix assets build:watch
30+
npm run --prefix assets build:watch
3131
```
3232

3333
Run the `build` command with watch mode set, providing for automatic assets rebuilds on every asset file change.
@@ -37,30 +37,37 @@ Additionally, in watch mode, the docs are built after every asset rebuild, meani
3737
### `lint`
3838

3939
```bash
40-
$ npm run --prefix assets lint
40+
npm run --prefix assets lint
4141
```
4242

4343
Lint all JavaScript files using [ESLint].
4444

4545
### `lint:fix`
4646

4747
```bash
48-
$ npm run --prefix assets lint:fix
48+
npm run --prefix assets lint:fix
4949
```
5050

5151
Lint and automatically fix all JavaScript files using [ESLint].
5252

5353
### `test`
5454

5555
```bash
56-
$ npm run --prefix assets test
56+
npm run --prefix assets test
5757
```
5858

59-
Run all the available JavaScript tests using [Karma].
59+
Run all the available JavaScript tests using [Vitest].
6060

61+
### `test:coverage`
62+
63+
```bash
64+
npm run --prefix assets test:coverage
65+
```
66+
67+
Run all the available JavaScript tests with code coverage using [Vitest].
6168

6269
[esbuild]: https://esbuild.github.io
6370
[Node.js]: https://nodejs.org/
6471
[npm]: https://www.npmjs.com/
6572
[ESLint]: https://eslint.org/
66-
[Karma]: https://karma-runner.github.io/
73+
[Vitest]: https://vitest.dev/

assets/karma.conf.js

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)