Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions test/error-handling/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { dirname } from 'node:path';
import { fileURLToPath } from 'node:url';
import { expect, test } from '@playwright/test';
import { createRsbuild } from '@rsbuild/core';
import { pluginTailwindCSS } from '../../src';

const __dirname = dirname(fileURLToPath(import.meta.url));

test('should fail with clear error when config file is missing', async () => {
const rsbuild = await createRsbuild({
cwd: __dirname,
rsbuildConfig: {
plugins: [
pluginTailwindCSS({
config: './does-not-exist.js',
}),
],
},
});

// We expect the build to fail
try {
await rsbuild.build();
throw new Error('Build was expected to fail, but it succeeded.');
} catch (err: unknown) {
const error = err as Error;
// Check for error message
// Rsbuild might wrap the error, so we check for generic failure or specific message
expect(error.message).toMatch(
/Rspack build failed|Cannot find module|ENOENT|no such file/i,
);
}
});
1 change: 1 addition & 0 deletions test/error-handling/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
console.log('Error handling test');