Skip to content

Commit 933a772

Browse files
fix: test
1 parent cb63d8e commit 933a772

File tree

12 files changed

+269
-123
lines changed

12 files changed

+269
-123
lines changed

package-lock.json

+208-118
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
"npm-run-all": "^4.1.5",
7373
"prettier": "^1.19.1",
7474
"standard-version": "^7.0.1",
75-
"webpack": "^4.41.3",
75+
"webpack": "^4.41.4",
7676
"webpack-cli": "^3.3.6",
7777
"webpack-dev-server": "^3.7.2"
7878
},

test/TestCases.test.js

+19-4
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,14 @@ function compareDirectory(actual, expected) {
2626
}
2727

2828
function compareWarning(actual, expectedFile) {
29-
if (!fs.existsSync(expectedFile)) return;
29+
if (!fs.existsSync(expectedFile)) {
30+
return;
31+
}
32+
33+
// eslint-disable-next-line global-require, import/no-dynamic-require
34+
const expected = require(expectedFile);
3035

31-
const expected = require(expectedFile); // eslint-disable-line global-require,import/no-dynamic-require
32-
expect(actual).toBe(expected);
36+
expect(actual.trim()).toBe(expected.trim());
3337
}
3438

3539
describe('TestCases', () => {
@@ -97,8 +101,19 @@ describe('TestCases', () => {
97101
}
98102

99103
const expectedDirectory = path.resolve(directoryForCase, 'expected');
104+
const expectedDirectoryByVersion = path.join(
105+
expectedDirectory,
106+
`webpack-${webpack.version[0]}`
107+
);
100108

101-
compareDirectory(outputDirectoryForCase, expectedDirectory);
109+
if (fs.existsSync(expectedDirectoryByVersion)) {
110+
compareDirectory(
111+
outputDirectoryForCase,
112+
expectedDirectoryByVersion
113+
);
114+
} else {
115+
compareDirectory(outputDirectoryForCase, expectedDirectory);
116+
}
102117

103118
const expectedWarning = path.resolve(directoryForCase, 'warnings.js');
104119
const actualWarning = stats.toString({
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.base {
2+
background: blue;
3+
}
4+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.base {
2+
background: blue;
3+
}
4+

test/cases/composes-async/webpack.config.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import Self from '../../../src';
22

3+
// TODO buggy in webpack@5
4+
35
module.exports = {
46
entry: './index.js',
57
module: {
+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
@import url(https://some/other/external/css);
2+
@import url(https://some/external/css);
3+
body {
4+
background: red;
5+
}
6+
7+
.c {
8+
background: red;
9+
}
10+
11+
.c {
12+
color: yellow;
13+
}
14+
15+
.b {
16+
background: red;
17+
}
18+
19+
.b {
20+
color: yellow;
21+
}
22+
23+
24+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/******/ (() => { // webpackBootstrap
2+
/******/ /************************************************************************/
3+
// extracted by mini-css-extract-plugin
4+
if(false) { var cssReload; }
5+
6+
/******/ })()
7+
;

0 commit comments

Comments
 (0)