Skip to content

Commit aefa927

Browse files
test(openapi-generator): replace ava with node:test
This commit replaces ava with the Node.js native test runner[^1]. The naive implementation ran each test in the test corpus serially, due to this nature of the native test runner's execution model[^2]: > Each test file is executed as if it was a regular script. That is, > if the test file itself uses node:test to define tests, all of those > tests will be executed within a single application thread, regardless > of the value of the concurrency option of test(). Since the function under test is synchronous and compute-bound, and Node.js is single-threaded, all the tests were executing serially and took over 30s to complete on my macbook. Consequently, this commit uses Node.js worker threads[^3] to spawn one worker per test-corpus file, limited to one worker per CPU core. In this configuration, all tests complete in 17s on my macbook. [^1]: https://nodejs.org/api/test.html [^2]: https://nodejs.org/api/test.html#test-runner-execution-model [^3]: https://nodejs.org/api/worker_threads.html
1 parent 13d437a commit aefa927

20 files changed

+861
-164
lines changed

.github/workflows/ci.yml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,15 @@ jobs:
1414

1515
strategy:
1616
matrix:
17-
node-version: [lts/-2, lts/-1, lts/*]
17+
node-version:
18+
# Skip lts/-2 while it refers to Node.js 14, since this version
19+
# does not come with Node.js's built-in test runner.
20+
# - lts/-2
21+
# Skip lts/-1 while it refers to Node.js 16, since this version
22+
# ships with a segfault when collecting code coverage with
23+
# Node.js's built-in test runner.
24+
# - lts/-1
25+
- lts/*
1826

1927
name: Node.js ${{ matrix.node-version }}
2028
steps:
@@ -27,11 +35,6 @@ jobs:
2735
cache: npm
2836
node-version: ${{ matrix.node-version }}
2937

30-
# Install npm greater-than-or-equal-to 7 so we can use npm workspaces.
31-
# We can remove this when Node.js 16 is the oldest LTS
32-
- name: Update npm
33-
run: npm install --global 'npm@>7'
34-
3538
- name: Install dependencies
3639
run: npm ci
3740

0 commit comments

Comments
 (0)