refactor waitForPlaywrightConsole helper

This commit is contained in:
Nacho Codoñer
2025-08-07 17:55:41 +02:00
parent 9a73cca587
commit af2f32cfbd
2 changed files with 9 additions and 3 deletions

View File

@@ -490,7 +490,13 @@ export async function runMeteorTests(tempDir, port, options = {}) {
return { meteorProcess, outputLines };
}
export async function waitForPlaywrightConsole(page, pattern, options = {}) {
/**
* Helper function to wait for a console message matching a pattern
* @param {string|RegExp} pattern
* @param {Object} options - Additional options
* @returns {Promise<unknown>}
*/
export async function waitForPlaywrightConsole(pattern, options = {}) {
const timeout = options.timeout || 30000; // Default 30 seconds timeout
const checkInterval = options.checkInterval || 100; // Check every 100ms by default

View File

@@ -171,7 +171,7 @@ describe('React App Bundling /', () => {
await appendFileContent(tempDir, 'client/main.jsx', {
content: 'if (Meteor.isDevelopment) console.log("Hello from dev client");',
});
await waitForPlaywrightConsole(page, 'Hello from dev client');
await waitForPlaywrightConsole('Hello from dev client');
// Update the server code
await appendFileContent(tempDir, 'server/main.js', {
@@ -224,7 +224,7 @@ describe('React App Bundling /', () => {
await appendFileContent(tempDir, 'client/main.jsx', {
content: 'if (Meteor.isProduction) console.log("Hello from prod client");',
});
await waitForPlaywrightConsole(page, 'Hello from prod client');
await waitForPlaywrightConsole('Hello from prod client');
// Update the server code
await appendFileContent(tempDir, 'server/main.js', {