From 9a73cca587e75d535a4823c33bf57127dc9ec710 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nacho=20Codo=C3=B1er?= Date: Thu, 7 Aug 2025 17:43:16 +0200 Subject: [PATCH] support test in watch mode in rspack integration --- tools/modern-tests/helpers.js | 7 ------ tools/modern-tests/react.test.js | 39 +++++++++++++++++++++++++++----- 2 files changed, 33 insertions(+), 13 deletions(-) diff --git a/tools/modern-tests/helpers.js b/tools/modern-tests/helpers.js index 7d4d03a49e..e2a349845e 100644 --- a/tools/modern-tests/helpers.js +++ b/tools/modern-tests/helpers.js @@ -468,13 +468,6 @@ export async function runMeteorTests(tempDir, port, options = {}) { ); } - // Wait for server to be up - console.log(`Waiting for test server to be available on port ${port}...`); - await waitOn({ - resources: [`http-get://localhost:${port}`], - timeout: 60000 - }); - // If we're checking test results, wait for the process to complete and check for failures if (options.checkTestResults) { console.log('Waiting for Meteor tests to complete...'); diff --git a/tools/modern-tests/react.test.js b/tools/modern-tests/react.test.js index 936c0034e6..042a531b73 100644 --- a/tools/modern-tests/react.test.js +++ b/tools/modern-tests/react.test.js @@ -247,11 +247,10 @@ describe('React App Bundling /', () => { }); test(`"meteor test" / should run tests with Rspack`, async () => { - // Run the Meteor app and wait for "restarted at" output const result = await runMeteorTests(tempDir, PORT, { waitForOutput: "=> App running at:", - commandOptions: ['--once'], - checkTestResults: true, + commandOptions: [], + checkTestResults: false, }); meteorProcess = result.meteorProcess; @@ -263,12 +262,40 @@ describe('React App Bundling /', () => { await assertFileExist(tempDir, '_build/test/test-rspack.js'); await assertFileExist(tempDir, '_build/test/test-meteor.js'); - // Note: We don't need to kill the meteor process here as it should have completed - // when using --once and checkTestResults: true + // Update the test code + await appendFileContent(tempDir, 'tests/main.js', { + content: 'console.log("Hello from test");', + }); + await waitForMeteorOutput( + result.outputLines, + 'Hello from test' + ); + + // Kill the meteor process + await killMeteorProcess(meteorProcess); + + // Ensure any process on the port is killed + await killProcessByPort(PORT); + }); + + test(`"meteor test --once" / should run tests once with Rspack`, async () => { + // Test the app with Rspack once + await runMeteorTests(tempDir, PORT, { + waitForOutput: "=> App running at:", + commandOptions: ['--once'], + checkTestResults: true, + }); + + // Wait for a margin + await wait(500); + + // Assert that the app files exists + await assertFileExist(tempDir, '_build/test/test-entry.js'); + await assertFileExist(tempDir, '_build/test/test-rspack.js'); + await assertFileExist(tempDir, '_build/test/test-meteor.js'); // Ensure any process on the port is killed await killProcessByPort(PORT); - await killProcessByPort('8080'); }); }); });