Skip to content

Commit cb559f2

Browse files
test: ensure empty options are working (#810)
1 parent 81ff67a commit cb559f2

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

test/__snapshots__/loader.test.js.snap

+26
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,32 @@ exports.push([module.id, \\"\\", \\"\\"]);
390390

391391
exports[`loader should compile with empty css entry point: warnings 1`] = `Array []`;
392392

393+
exports[`loader should compile with empty options: errors 1`] = `Array []`;
394+
395+
exports[`loader should compile with empty options: module (evaluated) 1`] = `
396+
Array [
397+
Array [
398+
1,
399+
"",
400+
"",
401+
],
402+
]
403+
`;
404+
405+
exports[`loader should compile with empty options: module 1`] = `
406+
"exports = module.exports = require(\\"../../lib/runtime/api.js\\")(false);
407+
// imports
408+
409+
410+
// module
411+
exports.push([module.id, \\"\\", \\"\\"]);
412+
413+
// exports
414+
"
415+
`;
416+
417+
exports[`loader should compile with empty options: warnings 1`] = `Array []`;
418+
393419
exports[`loader should throw error on invalid css syntax: errors 1`] = `
394420
Array [
395421
"ModuleBuildError: Module build failed (from \`replaced original path\`):

test/loader.test.js

+15
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,21 @@ describe('loader', () => {
4747
expect(stats.compilation.errors).toMatchSnapshot('errors');
4848
});
4949

50+
it('should compile with empty options', async () => {
51+
const config = { loader: { options: {} } };
52+
const testId = './empty.css';
53+
const stats = await webpack(testId, config);
54+
const { modules } = stats.toJson();
55+
const module = modules.find((m) => m.id === testId);
56+
57+
expect(module.source).toMatchSnapshot('module');
58+
expect(evaluated(module.source, modules)).toMatchSnapshot(
59+
'module (evaluated)'
60+
);
61+
expect(stats.compilation.warnings).toMatchSnapshot('warnings');
62+
expect(stats.compilation.errors).toMatchSnapshot('errors');
63+
});
64+
5065
it('should throws error when no loader for assets', async () => {
5166
const config = {
5267
rules: [

0 commit comments

Comments
 (0)