Skip to content
This repository was archived by the owner on Mar 8, 2020. It is now read-only.

Commit 12a4421

Browse files
committed
keep test utilities simple
1 parent 694c507 commit 12a4421

2 files changed

Lines changed: 10 additions & 26 deletions

File tree

test/rule.test.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,7 @@ test('should generate working rule for getting favicon tags', async t => {
5050
module: {
5151
rules: [rule],
5252
},
53-
}, {
54-
skipJs: false,
55-
});
53+
});
5654

5755
const actualTags = require(path.resolve(dist, 'main.js'));
5856
t.truthy(Array.isArray(actualTags));

test/util.js

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ module.exports.compiler = (config) => {
1818
config = merge(
1919
{
2020
entry: path.resolve(fixtures, 'entry.js'),
21-
plugins: []
21+
plugins: [],
2222
},
2323
config
2424
);
@@ -37,30 +37,16 @@ module.exports.compiler = (config) => {
3737
return webpack(config);
3838
}
3939

40-
module.exports.run = (compiler, { skipJs = true } = {}) => {
41-
if (skipJs) {
42-
tap(compiler, 'emit', 'Test', ({ assets }, callback) => {
43-
Object.keys(assets)
44-
.filter(asset => asset.match(/.js$/))
45-
.forEach(asset => {
46-
delete assets[asset];
47-
});
48-
49-
return callback();
50-
});
51-
}
52-
53-
return new Promise((resolve, reject) => {
54-
compiler.run((err, stats) => (err || stats.hasErrors())
55-
? reject(err || stats.toJson().errors)
56-
: resolve(stats)
57-
);
58-
});
59-
};
40+
module.exports.run = (compiler) => new Promise((resolve, reject) => {
41+
compiler.run((err, stats) => (err || stats.hasErrors())
42+
? reject(err || stats.toJson().errors)
43+
: resolve(stats)
44+
);
45+
});
6046

61-
module.exports.generate = (config, options) => module.exports.run(module.exports.compiler(config), options);
47+
module.exports.generate = (config) => module.exports.run(module.exports.compiler(config));
6248

63-
module.exports.compare = (a, b) => dircompare.compare(a, b, { compareContent: true }).then(diff =>
49+
module.exports.compare = (a, b) => dircompare.compare(a, b, { compareContent: true, excludeFilter: '*.js' }).then(diff =>
6450
diff.diffSet.filter(({ state }) => state !== 'equal')
6551
.map(({ path1, name1, path2, name2 }) => `${path.join(path1 || '', name1 + '')}${path.join(path2 || '', name2 + '')}`)
6652
);

0 commit comments

Comments
 (0)