From c8467b62ca3e683a7b010ad58219895bc2d800e7 Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Wed, 4 Dec 2024 18:17:50 +0000 Subject: [PATCH] test: disable colors in vite tests This forcefully removes the colors. --- .../vite/reuse-dep-optimization-cache.ts | 3 +- .../tests/vite/ssr-new-dep-optimization.ts | 31 +++++++++++++------ 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/tests/legacy-cli/e2e/tests/vite/reuse-dep-optimization-cache.ts b/tests/legacy-cli/e2e/tests/vite/reuse-dep-optimization-cache.ts index 9ffc9aa67c6a..26caf5a9afb3 100644 --- a/tests/legacy-cli/e2e/tests/vite/reuse-dep-optimization-cache.ts +++ b/tests/legacy-cli/e2e/tests/vite/reuse-dep-optimization-cache.ts @@ -19,7 +19,7 @@ export default async function () { ['serve', '--port', `${port}`], /bundle generation complete/, // Use CI:0 to force caching - { DEBUG: 'vite:deps', CI: '0' }, + { DEBUG: 'vite:deps', CI: '0', NO_COLOR: 'true' }, ); // Wait for vite to write to FS and stablize. @@ -33,7 +33,6 @@ export default async function () { // Terminate the dev-server await killAllProcesses(); - // The Node.js specific module should not be found await execAndWaitForOutputToMatch( 'ng', ['serve', '--port=0'], diff --git a/tests/legacy-cli/e2e/tests/vite/ssr-new-dep-optimization.ts b/tests/legacy-cli/e2e/tests/vite/ssr-new-dep-optimization.ts index d330cbf8f75d..d2dfb8b554b9 100644 --- a/tests/legacy-cli/e2e/tests/vite/ssr-new-dep-optimization.ts +++ b/tests/legacy-cli/e2e/tests/vite/ssr-new-dep-optimization.ts @@ -1,10 +1,14 @@ import assert from 'node:assert'; -import { setTimeout } from 'node:timers/promises'; -import { ng, waitForAnyProcessOutputToMatch } from '../../utils/process'; +import { + execAndWaitForOutputToMatch, + ng, + waitForAnyProcessOutputToMatch, +} from '../../utils/process'; import { installWorkspacePackages, uninstallPackage } from '../../utils/packages'; -import { ngServe, useSha } from '../../utils/project'; +import { useSha } from '../../utils/project'; import { getGlobalVariable } from '../../utils/env'; import { readFile, writeFile } from '../../utils/fs'; +import { findFreePort } from '../../utils/network'; export default async function () { assert( @@ -22,20 +26,27 @@ export default async function () { await useSha(); await installWorkspacePackages(); - const port = await ngServe(); + const port = await findFreePort(); + await execAndWaitForOutputToMatch( + 'ng', + ['serve', '--port', port.toString()], + /Application bundle generation complete/, + { CI: '0', NO_COLOR: 'true' }, + ); await validateResponse('/', /Hello,/); - const appConfigContentsUpdated = ` - import { provideAnimationsAsync } from '@angular/platform-browser/animations/async'; - ${(await readFile('src/app/app.config.ts')).replace('provideRouter(routes),', 'provideAnimationsAsync(), provideRouter(routes),')} - `; - await Promise.all([ waitForAnyProcessOutputToMatch( /new dependencies optimized: @angular\/platform-browser\/animations\/async/, 6000, ), - setTimeout(200).then(() => writeFile('src/app/app.config.ts', appConfigContentsUpdated)), + writeFile( + 'src/app/app.config.ts', + ` + import { provideAnimationsAsync } from '@angular/platform-browser/animations/async'; + ${(await readFile('src/app/app.config.ts')).replace('provideRouter(routes),', 'provideAnimationsAsync(), provideRouter(routes),')} + `, + ), ]); // Verify the app still works.