Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: finish all webpack test migration #2709

Merged
merged 7 commits into from
Apr 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions webpack-test/AbstractMethodError.unittest.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
"use strict";

const AbstractMethodError = require("../lib/AbstractMethodError");
// TODO: recover after we have this module
// const AbstractMethodError = require("../lib/AbstractMethodError");

describe("WebpackError", () => {
describe.skip("WebpackError", () => {
class Foo {
abstractMethod() {
return new AbstractMethodError();
Expand Down
3 changes: 2 additions & 1 deletion webpack-test/JavascriptParser.unittest.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
// const JavascriptParser = require("../lib/javascript/JavascriptParser");

describe.skip("JavascriptParser", () => {

it("filtered", () => {})
return
/* eslint-disable no-undef */
/* eslint-disable no-unused-vars */
/* eslint-disable no-inner-declarations */
Expand Down
5 changes: 3 additions & 2 deletions webpack-test/LazySet.unittest.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const LazySet = require("../lib/util/LazySet");
// TODO: recover
// const LazySet = require("../lib/util/LazySet");

describe("LazySet", () => {
describe.skip("LazySet", () => {
it("addAll", () => {
const a = new Set(["a"]);
const sut = new LazySet(a);
Expand Down
11 changes: 6 additions & 5 deletions webpack-test/LocalModulesHelpers.unittest.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
"use strict";

const {
addLocalModule,
getLocalModule
} = require("../lib/dependencies/LocalModulesHelpers");
// TODO: recover
// const {
// addLocalModule,
// getLocalModule
// } = require("../lib/dependencies/LocalModulesHelpers");

describe("LocalModulesHelpers", () => {
describe.skip("LocalModulesHelpers", () => {
describe("addLocalModule", () => {
it("returns a module var without special characters", () => {
const state = {
Expand Down
4 changes: 2 additions & 2 deletions webpack-test/ModuleDependencyError.unittest.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"use strict";

const path = require("path");
const ModuleDependencyError = require("../lib/ModuleDependencyError");
// const ModuleDependencyError = require("../lib/ModuleDependencyError");

describe("ModuleDependencyError", () => {
describe.skip("ModuleDependencyError", () => {
let env;

beforeEach(() => {
Expand Down
7 changes: 4 additions & 3 deletions webpack-test/MultiItemCache.unittest.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
"use strict";

const Cache = require("../lib/Cache");
const { ItemCacheFacade, MultiItemCache } = require("../lib/CacheFacade");
// TODO: recover
// const Cache = require("../lib/Cache");
// const { ItemCacheFacade, MultiItemCache } = require("../lib/CacheFacade");

describe("MultiItemCache", () => {
describe.skip("MultiItemCache", () => {
it("Throws when getting items from an empty Cache", () => {
const multiItemCache = new MultiItemCache(generateItemCaches(0));
expect(() => multiItemCache.get(_ => _())).toThrowError();
Expand Down
7 changes: 4 additions & 3 deletions webpack-test/MultiWatching.unittest.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
"use strict";

const SyncHook = require("tapable").SyncHook;
const MultiWatching = require("../lib/MultiWatching");

// TODO: recover
// const MultiWatching = require("../lib/MultiWatching");
//
const createWatching = () => {
return {
invalidate: jest.fn(),
Expand All @@ -21,7 +22,7 @@ const createCompiler = () => {
return compiler;
};

describe("MultiWatching", () => {
describe.skip("MultiWatching", () => {
let watchings;
let compiler;
let myMultiWatching;
Expand Down
7 changes: 4 additions & 3 deletions webpack-test/NullDependency.unittest.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
"use strict";

const NullDependency = require("../lib/dependencies/NullDependency");

describe("NullDependency", () => {
// TODO: recover
// const NullDependency = require("../lib/dependencies/NullDependency");
//
describe.skip("NullDependency", () => {
let env;

beforeEach(() => (env = {}));
Expand Down
2 changes: 1 addition & 1 deletion webpack-test/ProfilingPlugin.unittest.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use strict";

const path = require("path");
const ProfilingPlugin = require("../lib/debug/ProfilingPlugin");
// const ProfilingPlugin = require("../lib/debug/ProfilingPlugin");

describe.skip("Profiling Plugin", () => {
it("should persist the passed output path", () => {
Expand Down
10 changes: 6 additions & 4 deletions webpack-test/RawModule.unittest.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
"use strict";

const RawModule = require("../lib/RawModule");
const RequestShortener = require("../lib/RequestShortener");
// TODO: recover
// const RawModule = require("../lib/RawModule");
// const RequestShortener = require("../lib/RequestShortener");
const path = require("path");

describe("RawModule", () => {
describe.skip("RawModule", () => {
const source = "sourceStr attribute";
const identifier = "identifierStr attribute";
const readableIdentifier = "readableIdentifierStr attribute";
const myRawModule = new RawModule(source, identifier, readableIdentifier);
// TODO: recover this comment after we ahve RawModule
// const myRawModule = new RawModule(source, identifier, readableIdentifier);

describe("identifier", () => {
it("returns value for identifierStr attribute", () => {
Expand Down
7 changes: 4 additions & 3 deletions webpack-test/RequestShortener.unittest.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
"use strict";

const RequestShortener = require("../lib/RequestShortener");

describe("RequestShortener", () => {
// TODO: recover
// const RequestShortener = require("../lib/RequestShortener");
//
describe.skip("RequestShortener", () => {
it("should create RequestShortener and shorten with ./ file in directory", () => {
const shortener = new RequestShortener("/foo/bar");
expect(shortener.shorten("/foo/bar/some.js")).toEqual("./some.js");
Expand Down
18 changes: 10 additions & 8 deletions webpack-test/RuntimeTemplate.unittest.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
"use strict";

const RuntimeTemplate = require("../lib/RuntimeTemplate");
const RequestShortener = require("../lib/RequestShortener");

// TODO: recover
// const RuntimeTemplate = require("../lib/RuntimeTemplate");
// const RequestShortener = require("../lib/RequestShortener");
//
describe.skip("RuntimeTemplate.concatenation", () => {
it("no args", () => {
const runtimeTemplate = new RuntimeTemplate(
Expand Down Expand Up @@ -49,11 +50,12 @@ describe.skip("RuntimeTemplate.concatenation", () => {
});

describe("es6", () => {
const runtimeTemplate = new RuntimeTemplate(
undefined,
{ environment: { templateLiteral: true } },
new RequestShortener(__dirname)
);
// TODO: recover this comment after we have RuntimeTemplate
// const runtimeTemplate = new RuntimeTemplate(
// undefined,
// { environment: { templateLiteral: true } },
// new RequestShortener(__dirname)
// );

it("should prefer shorten variant #1", () => {
expect(runtimeTemplate.concatenation({ expr: 1 }, "a", { expr: 2 })).toBe(
Expand Down
4 changes: 3 additions & 1 deletion webpack-test/SemVer.unittest.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
// satisfyRuntimeCode
// } = require("../lib/util/semver");

describe("SemVer", () => {
describe.skip("SemVer", () => {
it("filtered", () => {})
return
const createRuntimeFunction = runtimeCodeFunction => {
const runtimeFunction = runtimeCodeFunction({
basicFunction: (args, body) => `(${args}) => {\n${body.join("\n")}\n}`,
Expand Down
5 changes: 3 additions & 2 deletions webpack-test/SortableSet.unittest.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
"use strict";

const SortableSet = require("../lib/util/SortableSet");
// TODO: recover
// const SortableSet = require("../lib/util/SortableSet");

describe("util/SortableSet", () => {
describe.skip("util/SortableSet", () => {
it("Can be constructed like a normal Set", () => {
const sortableSet = new SortableSet([1, 1, 1, 1, 1, 4, 5, 2], () => {});
expect(Array.from(sortableSet)).toEqual([1, 4, 5, 2]);
Expand Down
17 changes: 11 additions & 6 deletions webpack-test/Stats.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ describe("Stats", () => {
"hotModuleReplacement": false,
},
"name": "entryB.js",
"size": 4772,
"size": 4747,
"type": "asset",
},
{
Expand All @@ -149,25 +149,30 @@ describe("Stats", () => {
"hotModuleReplacement": false,
},
"name": "entryA.js",
"size": 3598,
"size": 3608,
"type": "asset",
},
{
"chunkNames": [],
"chunkNames": [
"chunkB",
],
"chunks": [
"fixtures_b_js",
"chunkB",
],
"emitted": true,
"info": {
"development": false,
"hotModuleReplacement": false,
},
"name": "fixtures_b_js.js",
"size": 157,
"name": "chunkB.js",
"size": 160,
"type": "asset",
},
],
"assetsByChunkName": {
"chunkB": [
"chunkB.js",
],
"entryA": [
"entryA.js",
],
Expand Down
16 changes: 10 additions & 6 deletions webpack-test/StatsTestCases.basictest.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,16 @@ const tests = fs
describe("StatsTestCases", () => {
jest.setTimeout(30000);
let stderr;
beforeEach(() => {
stderr = captureStdio(process.stderr, true);
});
afterEach(() => {
stderr.restore();
});
if (tests.length) {
beforeEach(() => {
stderr = captureStdio(process.stderr, true);
});
}
if (tests.length) {
afterEach(() => {
stderr.restore();
});
}
tests.forEach(testName => {
it("should print correct stats for " + testName, done => {
const outputDirectory = path.join(outputBase, testName);
Expand Down
5 changes: 3 additions & 2 deletions webpack-test/Template.unittest.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
"use strict";

const Template = require("../lib/Template");
// TODO: recover
// const Template = require("../lib/Template");

describe("Template", () => {
describe.skip("Template", () => {
it("should generate valid identifiers", () => {
expect(Template.toIdentifier("0abc-def9")).toBe("_0abc_def9");
});
Expand Down
5 changes: 3 additions & 2 deletions webpack-test/TestCasesHot.test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
const { describeCases } = require("./TestCases.template");
const webpack = require("@rspack/core").rspack;
const webpack = require("@rspack/core");

describe("TestCases", () => {
describeCases({
name: "hot",
plugins: [new webpack.HotModuleReplacementPlugin()]
// TODO: recover this line after we have this js plugin
// plugins: [new webpack.HotModuleReplacementPlugin()]
});
});
7 changes: 4 additions & 3 deletions webpack-test/URLAbsoluteSpecifier.unittest.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const { getScheme, getProtocol } = require("../lib/util/URLAbsoluteSpecifier");
// TODO: recover
// const { getScheme, getProtocol } = require("../lib/util/URLAbsoluteSpecifier");

/**
* @type {Array<{specifier: string, expected: string|undefined}>}
Expand Down Expand Up @@ -66,15 +67,15 @@ const samples = [
}
];

describe("getScheme", () => {
describe.skip("getScheme", () => {
samples.forEach(({ specifier, expected }, i) => {
it(`should handle ${specifier}`, () => {
expect(getScheme(specifier)).toBe(expected);
});
});
});

describe("getProtocol", () => {
describe.skip("getProtocol", () => {
samples.forEach(({ specifier, expected }, i) => {
it(`should handle ${specifier}`, () => {
expect(getProtocol(specifier)).toBe(
Expand Down
4 changes: 3 additions & 1 deletion webpack-test/WasmHashes.unittest.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,11 @@ const wasmHashes = {
};

for (const name of Object.keys(wasmHashes)) {
it("filtered", () => {})
continue
const { createHash, createReferenceHash, regExp } = wasmHashes[name]();

describe(name, () => {
describe.skip(name, () => {
const sizes = [
1,
2,
Expand Down
8 changes: 6 additions & 2 deletions webpack-test/WebpackError.unittest.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
"use strict";

const WebpackError = require("../lib/WebpackError");
// TODO: recover
// const WebpackError = require("../lib/WebpackError");

describe("WebpackError", () => {
// TODO: remove this class after we have real webpackError
class WebpackError {}

describe.skip("WebpackError", () => {
class CustomError extends WebpackError {
constructor(message) {
super();
Expand Down
2 changes: 1 addition & 1 deletion webpack-test/cases/mjs/type-module/package.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"type": "module"
"TODO: remember to recover `type: \"module\"`": ""
}
1 change: 0 additions & 1 deletion webpack-test/cases/mjs/type-module/test.filter.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

module.exports = () => {return false}


1 change: 1 addition & 0 deletions webpack-test/cases/mjs/type-module/test.fitler.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = () => {return false }
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
module.exports = function (config) {
return !config.module;
};
// module.exports = function (config) {
// return !config.module;
// };

module.exports = () => {return false}
8 changes: 5 additions & 3 deletions webpack-test/cases/parsing/typeof-non-module/test.filter.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
module.exports = function (config) {
return !config.module;
};
// module.exports = function (config) {
// return !config.module;
// };

module.exports = () => {return false}
6 changes: 6 additions & 0 deletions webpack-test/cases/wasm/v128/test.filter.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/**


const supportsWebAssembly = require("../../../helpers/supportsWebAssembly");
const supportsFeature = require("webassembly-feature");

Expand All @@ -6,3 +9,6 @@ module.exports = function (config) {
return false;
return supportsWebAssembly() && supportsFeature.simd();
};
*/

module.exports = () => {return false}
Loading