From af2f32cfbd7c2110e82b080b1e901265c3644e24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nacho=20Codo=C3=B1er?= Date: Thu, 7 Aug 2025 17:55:41 +0200 Subject: [PATCH] refactor waitForPlaywrightConsole helper --- tools/modern-tests/helpers.js | 8 +++++++- tools/modern-tests/react.test.js | 4 ++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/tools/modern-tests/helpers.js b/tools/modern-tests/helpers.js index e2a349845e..527c92a84e 100644 --- a/tools/modern-tests/helpers.js +++ b/tools/modern-tests/helpers.js @@ -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} + */ +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 diff --git a/tools/modern-tests/react.test.js b/tools/modern-tests/react.test.js index 042a531b73..6b6086ac57 100644 --- a/tools/modern-tests/react.test.js +++ b/tools/modern-tests/react.test.js @@ -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', {