diff --git a/tools/modern-tests/babel.test.js b/tools/modern-tests/babel.test.js index 376d0f13f2..9ca2966792 100644 --- a/tools/modern-tests/babel.test.js +++ b/tools/modern-tests/babel.test.js @@ -19,23 +19,41 @@ describe('Babel App Bundling /', () => { }, customAssertions: { afterRun: async ({ result }) => { + await assertFileExtensionModuleRules(result.outputLines); }, afterRunRebuildClient: async ({ allConsoleLogs }) => { // Check for HMR output as enabled by default - await waitForMeteorOutput(allConsoleLogs, /.*HMR.*Updated modules:*/); + await waitForMeteorOutput(allConsoleLogs, /.*HMR.*Updated modules:.*/); }, afterRunProduction: async ({ result }) => { + await assertFileExtensionModuleRules(result.outputLines); }, afterRunProductionRebuildClient: async ({ allConsoleLogs }) => { // Check for HMR to not be enabled in production-like mode await waitForMeteorOutput(allConsoleLogs, /.*HMR.*Updated modules:*/, { negate: true }); }, afterTest: async ({ result }) => { + await assertFileExtensionModuleRules(result.outputLines); }, afterTestOnce: async ({ result }) => { + await assertFileExtensionModuleRules(result.outputLines); }, afterBuild: async ({ result }) => { + await assertFileExtensionModuleRules(result.outputLines); }, } })); }); + +/** + * Helper function to assert that output contains expected file extension moduel rules + * @param {string[]} outputLines - Array of output lines to check + * @returns {Promise} + */ +export async function assertFileExtensionModuleRules(outputLines) { + // Check for custom and residual rules + await waitForMeteorOutput(outputLines, '/\\.(js|jsx)$/'); + await waitForMeteorOutput(outputLines, '/\\.(tsx|ts|mts|cts|mjs|cjs)$/'); + await waitForMeteorOutput(outputLines, '/\\.(graphql|gql)$/'); + await waitForMeteorOutput(outputLines, '/\\.(?:[mc]?js|jsx|[mc]?ts|tsx)$/i', { negate: true }); +} diff --git a/tools/modern-tests/coffeescript.test.js b/tools/modern-tests/coffeescript.test.js index 4c2dcfa972..1ba0172445 100644 --- a/tools/modern-tests/coffeescript.test.js +++ b/tools/modern-tests/coffeescript.test.js @@ -25,7 +25,7 @@ describe('CoffeeScript App Bundling /', () => { }, afterRunRebuildClient: async ({ allConsoleLogs }) => { // Check for HMR output as enabled by default - await waitForMeteorOutput(allConsoleLogs, /.*HMR.*Updated modules:*/); + await waitForMeteorOutput(allConsoleLogs, /.*HMR.*Updated modules:.*/); }, afterRunProduction: async ({ result }) => { await waitForCoffeescriptEnvs(result.outputLines); diff --git a/tools/modern-tests/react.test.js b/tools/modern-tests/react.test.js index b724e07f70..3bd09ccfbf 100644 --- a/tools/modern-tests/react.test.js +++ b/tools/modern-tests/react.test.js @@ -83,7 +83,7 @@ describe('React App Bundling /', () => { }, afterRunRebuildClient: async ({ allConsoleLogs }) => { // Check for HMR output as enabled by default - await waitForMeteorOutput(allConsoleLogs, /.*HMR.*Updated modules:*/); + await waitForMeteorOutput(allConsoleLogs, /.*HMR.*Updated modules:.*/); }, afterRunProduction: async ({ result }) => { await waitForReactEnvs(result.outputLines, { isJsxEnabled: true }); diff --git a/tools/modern-tests/typescript.test.js b/tools/modern-tests/typescript.test.js index 67468f7860..c52fec5d94 100644 --- a/tools/modern-tests/typescript.test.js +++ b/tools/modern-tests/typescript.test.js @@ -24,7 +24,7 @@ describe('TypeScript App Bundling /', () => { }, afterRunRebuildClient: async ({ allConsoleLogs }) => { // Check for HMR output as enabled by default - await waitForMeteorOutput(allConsoleLogs, /.*HMR.*Updated modules:*/); + await waitForMeteorOutput(allConsoleLogs, /.*HMR.*Updated modules:.*/); }, afterRunProduction: async ({ result }) => { await waitForTypeScriptEnvs(result.outputLines, { isTsxEnabled: true });