Skip to content

Commit

Permalink
test: pass publint options
Browse files Browse the repository at this point in the history
  • Loading branch information
chenjiahan committed Dec 11, 2024
1 parent 0a7efce commit cff1c10
Showing 1 changed file with 30 additions and 2 deletions.
32 changes: 30 additions & 2 deletions test/basic/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { stripVTControlCharacters as stripAnsi } from 'node:util';
import { expect, test } from '@playwright/test';
import { createRsbuild } from '@rsbuild/core';
import { pluginPublint } from '../../src';
import { proxyConsole } from '../helper';
import { stripVTControlCharacters as stripAnsi } from 'node:util';

const getPublintLogs = (logs: string[]) => {
const result: string[] = [];
Expand All @@ -15,7 +15,7 @@ const getPublintLogs = (logs: string[]) => {
return result;
};

test('should run publint as expected', async ({ page }) => {
test('should run publint as expected', async () => {
const { logs, restore } = proxyConsole();

const rsbuild = await createRsbuild({
Expand All @@ -40,3 +40,31 @@ test('should run publint as expected', async ({ page }) => {

restore();
});

test('should allow to pass publint options', async () => {
const { logs, restore } = proxyConsole();

const rsbuild = await createRsbuild({
cwd: __dirname,
rsbuildConfig: {
plugins: [
pluginPublint({
publintOptions: {
level: 'error',
},
}),
],
},
});

await expect(rsbuild.build()).rejects.toThrowError('Publint failed!');

expect(getPublintLogs(logs)).toEqual([
'error Publint found 3 errors:',
'error pkg.exports["."].types should be the first in the object as required by TypeScript.',
'error pkg.exports["."].import is ./dist/index.js but the file does not exist.',
'error pkg.exports["."].types is ./dist/index.d.ts but the file does not exist.',
]);

restore();
});

0 comments on commit cff1c10

Please sign in to comment.