Skip to content

Commit

Permalink
test(plugin): handle multiple plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
privatenumber committed Jan 23, 2024
1 parent d35279c commit b9e5b2a
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tests/fixtures.ts
Expand Up @@ -162,6 +162,10 @@ export const minification = {
'/src/index.js': 'export default ( stringVal ) => { return stringVal }',
};

export const define = {
'/src/index.js': 'export default () => [__TEST1__, __TEST2__]',
};

export const getHelpers = {
'/src/index.js': 'export default async () => {}',
};
Expand Down
28 changes: 28 additions & 0 deletions tests/specs/plugin.ts
Expand Up @@ -750,5 +750,33 @@ export default testSuite(({ describe }, webpack: typeof webpack4 | typeof webpac
webpack,
)).resolves.toBeTruthy();
});

test('multiple plugins', async () => {
const built = await build(
fixtures.define,
(config) => {
configureEsbuildMinifyPlugin(config);
config.plugins?.push(
new EsbuildPlugin({
define: {
__TEST1__: '123',
},
}),
new EsbuildPlugin({
define: {
__TEST2__: '321',
},
}),
);
},
webpack,
);

expect(built.stats.hasWarnings()).toBe(false);
expect(built.stats.hasErrors()).toBe(false);

const exportedFunction = built.require('/dist/');
expect(exportedFunction('hello world')).toStrictEqual([123, 321]);
});
});
});

0 comments on commit b9e5b2a

Please sign in to comment.