Skip to content

Commit 5431e4b

Browse files
test: refactor
1 parent 9107d52 commit 5431e4b

File tree

6 files changed

+37
-78
lines changed

6 files changed

+37
-78
lines changed

package-lock.json

Lines changed: 17 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
"stylus": "^0.54.8",
9090
"stylus-loader": "^4.3.0",
9191
"url-loader": "^4.1.1",
92-
"webpack": "^5.33.2"
92+
"webpack": "^5.34.0"
9393
},
9494
"keywords": [
9595
"webpack",

test/__snapshots__/import-option.test.js.snap

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1867,31 +1867,6 @@ Warning
18671867

18681868
exports[`"import" option should work with 'false' aliases: errors 1`] = `Array []`;
18691869

1870-
exports[`"import" option should work with 'false' aliases: module 1`] = `
1871-
"// Imports
1872-
import ___CSS_LOADER_API_IMPORT___ from \\"../../../src/runtime/api.js\\";
1873-
var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(function(i){return i[1]});
1874-
// Module
1875-
___CSS_LOADER_EXPORT___.push([module.id, \\"@import \\\\\\"/style.css\\\\\\";\\\\n\\\\n.class {\\\\n color: red;\\\\n}\\", \\"\\"]);
1876-
// Exports
1877-
export default ___CSS_LOADER_EXPORT___;
1878-
"
1879-
`;
1880-
1881-
exports[`"import" option should work with 'false' aliases: result 1`] = `
1882-
Array [
1883-
Array [
1884-
"./import/false-alias.css",
1885-
"@import \\"/style.css\\";
1886-
1887-
.class {
1888-
color: red;
1889-
}",
1890-
"",
1891-
],
1892-
]
1893-
`;
1894-
18951870
exports[`"import" option should work with 'false' aliases: warnings 1`] = `Array []`;
18961871

18971872
exports[`"import" option should work with a value equal to "false": errors 1`] = `Array []`;

test/__snapshots__/url-option.test.js.snap

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -657,18 +657,6 @@ Warning
657657

658658
exports[`"url" option should work with 'false' aliases: errors 1`] = `Array []`;
659659

660-
exports[`"url" option should work with 'false' aliases: result 1`] = `
661-
Array [
662-
Array [
663-
"./url/false-alias.css",
664-
".class {
665-
background-image: url(/logo.png);
666-
}",
667-
"",
668-
],
669-
]
670-
`;
671-
672660
exports[`"url" option should work with 'false' aliases: warnings 1`] = `Array []`;
673661

674662
exports[`"url" option should work with a value equal to "Function": errors 1`] = `Array []`;

test/import-option.test.js

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import fs from "fs";
22
import path from "path";
33

4+
import webpack from "webpack";
5+
46
import {
57
compile,
68
getCompiler,
@@ -10,6 +12,8 @@ import {
1012
getWarnings,
1113
} from "./helpers/index";
1214

15+
const isWebpack5 = webpack.version.startsWith(5);
16+
1317
describe('"import" option', () => {
1418
it("should work when not specified", async () => {
1519
const compiler = getCompiler("./import/import.js");
@@ -210,18 +214,23 @@ describe('"import" option', () => {
210214
],
211215
},
212216
resolve: {
213-
alias: { "/style.css": false },
217+
alias: {
218+
"/style.css": isWebpack5
219+
? false
220+
: path.resolve(__dirname, "./fixtures/import/alias.css"),
221+
},
214222
},
215223
}
216224
);
217225
const stats = await compile(compiler);
218226

219-
expect(getModuleSource("./import/false-alias.css", stats)).toMatchSnapshot(
220-
"module"
221-
);
222-
expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot(
223-
"result"
224-
);
227+
// TODO uncomment after drop webpack v4
228+
// expect(getModuleSource("./import/false-alias.css", stats)).toMatchSnapshot(
229+
// "module"
230+
// );
231+
// expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot(
232+
// "result"
233+
// );
225234
expect(getWarnings(stats)).toMatchSnapshot("warnings");
226235
expect(getErrors(stats)).toMatchSnapshot("errors");
227236
});

test/url-option.test.js

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -284,19 +284,6 @@ describe('"url" option', () => {
284284
"./url/false-alias.js",
285285
{},
286286
{
287-
output: isWebpack5
288-
? {
289-
path: path.resolve(__dirname, "./outputs"),
290-
filename: "[name].bundle.js",
291-
chunkFilename: "[name].chunk.js",
292-
publicPath: "/webpack/public/path/",
293-
}
294-
: {
295-
path: path.resolve(__dirname, "./outputs"),
296-
filename: "[name].bundle.js",
297-
chunkFilename: "[name].chunk.js",
298-
publicPath: "/",
299-
},
300287
module: {
301288
rules: [
302289
{
@@ -332,9 +319,9 @@ describe('"url" option', () => {
332319
// expect(getModuleSource("./url/false-alias.css", stats)).toMatchSnapshot(
333320
// "module"
334321
// );
335-
expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot(
336-
"result"
337-
);
322+
// expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot(
323+
// "result"
324+
// );
338325
expect(getWarnings(stats)).toMatchSnapshot("warnings");
339326
expect(getErrors(stats)).toMatchSnapshot("errors");
340327
});

0 commit comments

Comments
 (0)