Skip to content

Commit 86dc788

Browse files
committed
refactor(test): configureLoaderRule() will be easier to test
1 parent 39cb9bd commit 86dc788

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

test/config-generator.js

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,18 +1016,26 @@ describe('The config-generator function', () => {
10161016
});
10171017

10181018
describe('Test configureLoaderRule()', () => {
1019-
it('configure rule for "eslint"', () => {
1020-
const config = createConfig();
1019+
let config;
1020+
1021+
const getLoader = (loaderName) => {
1022+
const webpackConfig = configGenerator(config);
1023+
return webpackConfig.module.rules.find(rule => rule.loader === loaderName);
1024+
};
1025+
1026+
beforeEach(() => {
1027+
config = createConfig();
1028+
config.outputPath = '/tmp/public/build';
10211029
config.setPublicPath('/');
1030+
});
1031+
1032+
it('configure rule for "eslint"', () => {
10221033
config.enableEslintLoader();
10231034
config.configureLoaderRule('eslint', (loader) => {
10241035
loader.test = /\.(jsx?|vue)/;
10251036
});
10261037

1027-
const webpackConfig = configGenerator(config);
1028-
const eslintLoader = webpackConfig.module.rules.find(rule => rule.loader === 'eslint-loader');
1029-
1030-
expect(eslintLoader).to.deep.equals({
1038+
expect(getLoader('eslint-loader')).to.deep.equals({
10311039
test: /\.(jsx?|vue)/,
10321040
enforce: 'pre',
10331041
exclude: /node_modules/,

0 commit comments

Comments
 (0)