oxc/napi/parser/test/parse.test.mjs
ottomated 67a7bde4c6 feat(napi/parser)!: add typings to napi/parser (#6796)
- Added TypeScript annotation for `ParseResult.program`
- Modified the entrypoint for `oxc-parser` to allow wrapping the napi functions
- Updated `index.js` to parse the `program` string into a JSON object
- Updated tests
- Added a dependency on `@oxc/types`
2024-10-24 13:08:59 +00:00

21 lines
552 B
JavaScript

import { assert, describe, it } from 'vitest';
import * as oxc from '../index.js';
describe('parse', () => {
const code = '/* comment */ foo';
it('matches output', () => {
const ret = oxc.parseSync(code);
assert(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(ret.program.body.length == 1);
assert(ret.errors.length == 0);
assert(ret.comments.length == 1);
});
});