Skip to content

Commit

Permalink
chore: migrate config test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
LingyuCoder committed Apr 23, 2024
1 parent 332b127 commit 5792887
Show file tree
Hide file tree
Showing 12 changed files with 64 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ webpack-dist

.pnpm-store/

!packages/rspack/tests/configCases/target
!packages/rspack-test-tools/tests/configCases/target
packages/rspack/tests/js
packages/rspack/tests/fixtures/temp-*
packages/rspack/tests/cssExtract/js
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const fs = require("fs");

it("basic", () => {
const os = require("os");
const cpus = os.cpus();
expect(cpus.length).toBeGreaterThan(0);
});

it("format", () => {
const content = fs.readFileSync(__filename, "utf-8");
expect(content).toMatch(/.cpus/);
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
target: "async-node"
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const cjs = require("./lib/cjs");
const esm = require("./lib/esm");

exports.getFilePath = async function () {
const cjsLib = await cjs.getFilePath();
const esmLib = await esm.getFilePath();
return ["cjs.js", cjsLib, esmLib].join("|");
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import cjs from "./lib/cjs";
import { getFilePath as esmGetFilePath } from "./lib/esm";

export async function getFilePath() {
const cjsLib = await cjs.getFilePath();
const esmLib = await esmGetFilePath();
return ["esm.js", cjsLib, esmLib].join("|");
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const cjs = require("./cjs");
const esm = require("./esm");

it("should mix cjs and esm works", async () => {
expect(await cjs.getFilePath()).toBe("cjs.js|lib/cjs.js|lib/esm.js");
expect(await esm.getFilePath()).toBe("esm.js|lib/cjs.js|lib/esm.js");
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
exports.getFilePath = async function () {
return "lib/cjs.js";
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export async function getFilePath() {
return "lib/esm.js";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
target: ["node", "es5"]
};
12 changes: 12 additions & 0 deletions packages/rspack-test-tools/tests/configCases/target/node/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const fs = require("fs");

it("basic", () => {
const os = require("os");
const cpus = os.cpus();
expect(cpus.length).toBeGreaterThan(0);
});

it("format", () => {
const content = fs.readFileSync(__filename, "utf-8");
expect(content).toMatch(/.cpus/);
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
target: "node"
};
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { ModuleFederationPluginV1: ModuleFederationPlugin } = require("@rspack/core").container;
const { ModuleFederationPluginV1: ModuleFederationPlugin } = require("../../../../").container;

/** @type {ConstructorParameters<typeof ModuleFederationPlugin>[0]} */
const common = {
Expand Down

0 comments on commit 5792887

Please sign in to comment.