support test in watch mode in rspack integration

This commit is contained in:
Nacho Codoñer
2025-08-07 17:43:16 +02:00
parent 2efee8dddc
commit 9a73cca587
2 changed files with 33 additions and 13 deletions

View File

@@ -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...');

View File

@@ -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');
});
});
});