Skip to content

Commit

Permalink
fix: try to fix the random test failed of rspack-cli
Browse files Browse the repository at this point in the history
  • Loading branch information
LingyuCoder committed Sep 30, 2024
1 parent a193dcd commit fca794e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
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

0 comments on commit fca794e

Please sign in to comment.