|
1 | | -import path from "node:path"; |
| 1 | +import path from 'node:path'; |
2 | 2 |
|
3 | | -import { describe, expect, it } from "vitest"; |
| 3 | +import { describe, expect, it } from 'vitest'; |
4 | 4 |
|
5 | | -import { execa } from "execa"; |
| 5 | +import { execa } from 'execa'; |
6 | 6 |
|
7 | 7 | const PACKAGE_ROOT_PATH = path.dirname(import.meta.dirname); |
8 | | -const ENTRY_POINT_PATH = path.join(PACKAGE_ROOT_PATH, "src/index.js"); |
| 8 | +const ENTRY_POINT_PATH = path.join(PACKAGE_ROOT_PATH, 'src/index.js'); |
9 | 9 |
|
10 | 10 | async function runOxlint(cwd: string, args: string[] = []) { |
11 | | - return await execa("node", [ENTRY_POINT_PATH, ...args], { |
| 11 | + return await execa('node', [ENTRY_POINT_PATH, ...args], { |
12 | 12 | cwd: path.join(PACKAGE_ROOT_PATH, cwd), |
13 | 13 | reject: false, |
14 | 14 | }); |
15 | 15 | } |
16 | 16 |
|
17 | 17 | function normalizeOutput(output: string): string { |
18 | 18 | return output |
19 | | - .replace(/Finished in \d+(\.\d+)?(s|ms|us|ns)/, "Finished in Xms") |
20 | | - .replace(/using \d+ threads./, "using X threads."); |
| 19 | + .replace(/Finished in \d+(\.\d+)?(s|ms|us|ns)/, 'Finished in Xms') |
| 20 | + .replace(/using \d+ threads./, 'using X threads.'); |
21 | 21 | } |
22 | 22 |
|
23 | | -describe("cli options for bundling", () => { |
24 | | - it("should lint a directory without errors", async () => { |
| 23 | +describe('cli options for bundling', () => { |
| 24 | + it('should lint a directory without errors', async () => { |
25 | 25 | const { stdout, exitCode } = await runOxlint( |
26 | | - "test/fixtures/built_in_no_errors" |
| 26 | + 'test/fixtures/built_in_no_errors', |
27 | 27 | ); |
28 | 28 |
|
29 | 29 | expect(exitCode).toBe(0); |
30 | 30 | expect(normalizeOutput(stdout)).toMatchSnapshot(); |
31 | 31 | }); |
32 | 32 |
|
33 | | - it("should lint a directory with errors", async () => { |
| 33 | + it('should lint a directory with errors', async () => { |
34 | 34 | const { stdout, exitCode } = await runOxlint( |
35 | | - "test/fixtures/built_in_errors" |
| 35 | + 'test/fixtures/built_in_errors', |
36 | 36 | ); |
37 | 37 |
|
38 | 38 | expect(exitCode).toBe(1); |
39 | 39 | expect(normalizeOutput(stdout)).toMatchSnapshot(); |
40 | 40 | }); |
41 | 41 |
|
42 | | - it.only("should load a custom plugin", async () => { |
| 42 | + it.only('should load a custom plugin', async () => { |
43 | 43 | const { stdout, stderr, exitCode } = await runOxlint( |
44 | | - "test/fixtures/basic_custom_plugin" |
| 44 | + 'test/fixtures/basic_custom_plugin', |
45 | 45 | ); |
46 | | - console.log("stdout", stdout, "stderr", stderr); |
| 46 | + console.log('stdout', stdout, 'stderr', stderr); |
47 | 47 |
|
48 | 48 | expect(exitCode).toBe(0); |
49 | 49 | expect(normalizeOutput(stdout)).toMatchSnapshot(); |
50 | 50 | }); |
51 | 51 |
|
52 | | - it("should report an error if a custom plugin cannot be loaded", async () => { |
| 52 | + it('should report an error if a custom plugin cannot be loaded', async () => { |
53 | 53 | const { stdout, exitCode } = await runOxlint( |
54 | | - "test/fixtures/missing_custom_plugin" |
| 54 | + 'test/fixtures/missing_custom_plugin', |
55 | 55 | ); |
56 | 56 |
|
57 | 57 | expect(exitCode).toBe(1); |
|
0 commit comments