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: try to fix the randomly failed of @rspack/cli test cases #8030

Merged
merged 1 commit into from
Sep 30, 2024
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
2 changes: 2 additions & 0 deletions packages/rspack-cli/tests/build/issue-6359/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ it("should not have `process.env.WEBPACK_SERVE` set on build mode", async () =>

it("should have `process.env.WEBPACK_SERVE` set on serve mode", async () => {
await runWatch(__dirname, ["serve"], { killString: /rspack compiled/i });
// wait 1s to make sure the assets have been generated
await new Promise(resolve => setTimeout(resolve, 1000));
const mainJs = await readFile(resolve(__dirname, "dist/main.js"), "utf-8");

expect(mainJs).toContain("WEBPACK_SERVE=true");
Expand Down
3 changes: 1 addition & 2 deletions packages/rspack-cli/tests/build/issue-6359/rspack.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const path = require("path");
const { WEBPACK_SERVE } = process.env;
module.exports = /** @type {import('@rspack/cli').Configuration} */ {
mode: "production",
entry: "./entry.js",
Expand All @@ -12,7 +11,7 @@ module.exports = /** @type {import('@rspack/cli').Configuration} */ {
apply(compiler) {
new compiler.webpack.DefinePlugin({
DEFINE_ME: JSON.stringify(
`WEBPACK_SERVE=${WEBPACK_SERVE ?? "<EMPTY>"}`
`WEBPACK_SERVE=${process.env.WEBPACK_SERVE ?? "<EMPTY>"}`
)
}).apply(compiler);
}
Expand Down
Loading