Skip to content

Commit

Permalink
refactor(napi): use vitest (#6307)
Browse files Browse the repository at this point in the history
  • Loading branch information
Boshen committed Oct 6, 2024
1 parent 58a8615 commit 5b5daec
Show file tree
Hide file tree
Showing 15 changed files with 926 additions and 341 deletions.
10 changes: 2 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -274,13 +274,7 @@ jobs:
cache-key: warm
- uses: ./.github/actions/pnpm
if: steps.filter.outputs.src == 'true'
- name: Test napi/parser
run: pnpm build && pnpm test
- run: pnpm run build
if: steps.filter.outputs.src == 'true'
working-directory: napi/parser
- name: Test napi/transform
if: steps.filter.outputs.src == 'true'
working-directory: napi/transform
run: pnpm build && pnpm test
- run: git diff --exit-code
- run: pnpm run test
if: steps.filter.outputs.src == 'true'
2 changes: 1 addition & 1 deletion napi/minify/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"private": true,
"scripts": {
"build": "napi build --platform --release",
"test": "node test.mjs"
"test": "echo 'skip'"
},
"engines": {
"node": ">=14.*"
Expand Down
8 changes: 1 addition & 7 deletions napi/parser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
"private": true,
"scripts": {
"build": "napi build --platform --release",
"test": "node test.mjs",
"bench": "node parse.bench.mjs"
"test": "vitest run ./test"
},
"engines": {
"node": ">=14.*"
Expand All @@ -22,10 +21,5 @@
"x86_64-apple-darwin",
"aarch64-apple-darwin"
]
},
"devDependencies": {
"@napi-rs/cli": "catalog:",
"es-module-lexer": "^1.4.1",
"tinybench": "^2.6.0"
}
}
75 changes: 0 additions & 75 deletions napi/parser/parse.bench.mjs

This file was deleted.

21 changes: 0 additions & 21 deletions napi/parser/test.mjs

This file was deleted.

17 changes: 17 additions & 0 deletions napi/parser/test/module_lexer.test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { assert, describe, it } from 'vitest';

import oxc from './index.js';

describe('module lexer', () => {
const code = 'export { foo }';

it('matches output', () => {
const ret = oxc.moduleLexerSync(code);
assert(ret.exports.length == 1);
});

it('matches output async ', async () => {
const ret = await oxc.moduleLexerAsync(code);
assert(ret.exports.length == 1);
});
});
21 changes: 21 additions & 0 deletions napi/parser/test/parse.test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { assert, describe, it } from 'vitest';

import oxc from './index.js';

describe('parse', () => {
const code = '/* comment */ foo';

it('matches output', () => {
const ret = oxc.parseSync(code);
assert(JSON.parse(ret.program).body.length == 1);
assert(ret.errors.length == 0);
assert(ret.comments.length == 1);
});

it('matches output async ', async () => {
const ret = await oxc.parseAsync(code);
assert(JSON.parse(ret.program).body.length == 1);
assert(ret.errors.length == 0);
assert(ret.comments.length == 1);
});
});
102 changes: 0 additions & 102 deletions napi/parser/test_module_lexer.mjs

This file was deleted.

2 changes: 1 addition & 1 deletion napi/transform/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"private": true,
"scripts": {
"build": "napi build --platform --release",
"test": "node test.mjs"
"test": "vitest run ./test"
},
"engines": {
"node": ">=14.*"
Expand Down
Loading

0 comments on commit 5b5daec

Please sign in to comment.