Skip to content

Commit 005d4c3

Browse files
committed
Native test runner
1 parent 4c98f40 commit 005d4c3

File tree

7 files changed

+45
-1186
lines changed

7 files changed

+45
-1186
lines changed

README.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ After `yarn build/npm run build` command, you can see `package-template.[darwin|
2525

2626
### Test
2727

28-
With [ava](https://github.com/avajs/ava), run `yarn test/npm run test` to testing native addon. You can also switch to another testing framework if you want.
28+
With [`node:test`](https://nodejs.org/api/test.html), run `node --test` to test native addon. You can also switch to another testing framework if you want.
2929

3030
### CI
3131

@@ -57,15 +57,16 @@ In this package, we choose a better way to solve this problem. We release differ
5757

5858
And you will see:
5959

60-
```bash
61-
$ ava --verbose
62-
63-
✔ sync function from native code
64-
✔ sleep function from native code (201ms)
65-
66-
67-
2 tests passed
68-
✨ Done in 1.12s.
60+
```
61+
✔ sync function from native code (0.342041ms)
62+
ℹ tests 1
63+
ℹ suites 0
64+
ℹ pass 1
65+
ℹ fail 0
66+
ℹ cancelled 0
67+
ℹ skipped 0
68+
ℹ todo 0
69+
ℹ duration_ms 101.22675
6970
```
7071

7172
## Release package

__test__/index.spec.ts

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

package.json

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
"format:rs": "cargo fmt",
6060
"lint": "oxlint .",
6161
"prepublishOnly": "napi prepublish -t npm",
62-
"test": "ava",
62+
"test": "node --test",
6363
"preversion": "napi build --platform && git add .",
6464
"version": "napi version",
6565
"prepare": "husky"
@@ -70,7 +70,7 @@
7070
"@napi-rs/cli": "^3.2.0",
7171
"@taplo/cli": "^0.7.0",
7272
"@tybys/wasm-util": "^0.10.0",
73-
"ava": "^6.4.1",
73+
"@types/node": "^24.7.0",
7474
"chalk": "^5.6.2",
7575
"husky": "^9.1.7",
7676
"lint-staged": "^16.1.6",
@@ -91,13 +91,6 @@
9191
"taplo format"
9292
]
9393
},
94-
"ava": {
95-
"extensions": {
96-
"ts": "module"
97-
},
98-
"timeout": "2m",
99-
"workerThreads": false
100-
},
10194
"prettier": {
10295
"printWidth": 120,
10396
"semi": false,

test/index.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import test from 'node:test'
2+
import assert from 'node:assert/strict'
3+
4+
import { plus100 } from '../index.js'
5+
6+
test('sync function from native code', () => {
7+
const fixture = 42
8+
assert.equal(plus100(fixture), fixture + 100)
9+
})
File renamed without changes.

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"rewriteRelativeImportExtensions": true,
88
"erasableSyntaxOnly": true,
99
"verbatimModuleSyntax": true,
10-
"types": []
10+
"types": ["node"]
1111
},
1212
"include": ["."],
1313
"exclude": ["node_modules"]

0 commit comments

Comments
 (0)