diff --git a/napi/oxlint/test/__snapshots__/e2e.test.ts.snap b/napi/oxlint/test/__snapshots__/e2e.test.ts.snap index a14d8331ea09a..81c9c2d647421 100644 --- a/napi/oxlint/test/__snapshots__/e2e.test.ts.snap +++ b/napi/oxlint/test/__snapshots__/e2e.test.ts.snap @@ -55,7 +55,7 @@ Found 3 warnings and 3 errors. Finished in Xms on 1 file using X threads." `; -exports[`oxlint CLI > should lint a directory with errors 1`] = ` +exports[`oxlint CLI > should lint a directory with errors with JS plugins enabled 1`] = ` " x ]8;;https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-debugger.html\\eslint(no-debugger)]8;;\\: \`debugger\` statement is not allowed ,-[index.js:1:1] @@ -68,7 +68,25 @@ Found 0 warnings and 1 error. Finished in Xms on 1 file using X threads." `; -exports[`oxlint CLI > should lint a directory without errors 1`] = ` +exports[`oxlint CLI > should lint a directory with errors without JS plugins enabled 1`] = ` +" + x ]8;;https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-debugger.html\\eslint(no-debugger)]8;;\\: \`debugger\` statement is not allowed + ,-[index.js:1:1] + 1 | debugger; + : ^^^^^^^^^ + \`---- + help: Remove the debugger statement + +Found 0 warnings and 1 error. +Finished in Xms on 1 file using X threads." +`; + +exports[`oxlint CLI > should lint a directory without errors with JS plugins enabled 1`] = ` +"Found 0 warnings and 0 errors. +Finished in Xms on 1 file using X threads." +`; + +exports[`oxlint CLI > should lint a directory without errors without JS plugins enabled 1`] = ` "Found 0 warnings and 0 errors. Finished in Xms on 1 file using X threads." `; diff --git a/napi/oxlint/test/e2e.test.ts b/napi/oxlint/test/e2e.test.ts index 59330fc50185e..4fdafd70e7469 100644 --- a/napi/oxlint/test/e2e.test.ts +++ b/napi/oxlint/test/e2e.test.ts @@ -7,13 +7,17 @@ import { execa } from 'execa'; const PACKAGE_ROOT_PATH = path.dirname(import.meta.dirname); const ENTRY_POINT_PATH = path.join(PACKAGE_ROOT_PATH, 'dist/index.js'); -async function runOxlint(cwd: string, args: string[] = []) { - return await execa('node', [ENTRY_POINT_PATH, '--experimental-js-plugins', ...args], { +async function runOxlintWithoutPlugins(cwd: string, args: string[] = []) { + return await execa('node', [ENTRY_POINT_PATH, ...args], { cwd: path.join(PACKAGE_ROOT_PATH, cwd), reject: false, }); } +async function runOxlint(cwd: string, args: string[] = []) { + return await runOxlintWithoutPlugins(cwd, ['--experimental-js-plugins', ...args]); +} + function normalizeOutput(output: string): string { return output .replace(/Finished in \d+(\.\d+)?(s|ms|us|ns)/, 'Finished in Xms') @@ -21,13 +25,25 @@ function normalizeOutput(output: string): string { } describe('oxlint CLI', () => { - it('should lint a directory without errors', async () => { + it('should lint a directory without errors without JS plugins enabled', async () => { + const { stdout, exitCode } = await runOxlintWithoutPlugins('test/fixtures/built_in_no_errors'); + expect(exitCode).toBe(0); + expect(normalizeOutput(stdout)).toMatchSnapshot(); + }); + + it('should lint a directory with errors without JS plugins enabled', async () => { + const { stdout, exitCode } = await runOxlintWithoutPlugins('test/fixtures/built_in_errors'); + expect(exitCode).toBe(1); + expect(normalizeOutput(stdout)).toMatchSnapshot(); + }); + + it('should lint a directory without errors with JS plugins enabled', async () => { const { stdout, exitCode } = await runOxlint('test/fixtures/built_in_no_errors'); expect(exitCode).toBe(0); expect(normalizeOutput(stdout)).toMatchSnapshot(); }); - it('should lint a directory with errors', async () => { + it('should lint a directory with errors with JS plugins enabled', async () => { const { stdout, exitCode } = await runOxlint('test/fixtures/built_in_errors'); expect(exitCode).toBe(1); expect(normalizeOutput(stdout)).toMatchSnapshot();