From e18d0736fb73bb4edf8d2172801de56bafc5c37f Mon Sep 17 00:00:00 2001 From: Aidan Pine Date: Thu, 2 Jul 2026 15:45:23 -0700 Subject: [PATCH 1/2] fix(tests): fix spec tests after angular v21 upgrade --- packages/studio-web/src/test.ts | 22 +++++++++++++++++++--- packages/studio-web/tsconfig.spec.json | 1 + 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/packages/studio-web/src/test.ts b/packages/studio-web/src/test.ts index 6b0f19187..e633d1be8 100644 --- a/packages/studio-web/src/test.ts +++ b/packages/studio-web/src/test.ts @@ -1,4 +1,20 @@ -// The testing environment is now initialized automatically by Angular, and the tests -// are found automatically, so no need to do much here. - +// Angular no longer requires enumerating spec files here; the karma builder +// finds them automatically. +// +// The test environment still needs to be initialized explicitly, though: +// without it, the first NgModule compiled via TestBed silently leaves +// Angular's internal module registry in a broken state (surfaces later as +// `TypeError: Cannot read properties of null (reading 'ngModule')` from +// completely unrelated tests). `@angular/platform-browser-dynamic/testing` +// (the pre-v21 way to do this) no longer exists; this is its replacement. import "zone.js/testing"; +import { getTestBed } from "@angular/core/testing"; +import { + BrowserTestingModule, + platformBrowserTesting, +} from "@angular/platform-browser/testing"; + +getTestBed().initTestEnvironment( + BrowserTestingModule, + platformBrowserTesting(), +); diff --git a/packages/studio-web/tsconfig.spec.json b/packages/studio-web/tsconfig.spec.json index 669344f8d..0f5af4676 100644 --- a/packages/studio-web/tsconfig.spec.json +++ b/packages/studio-web/tsconfig.spec.json @@ -2,6 +2,7 @@ { "extends": "./tsconfig.json", "compilerOptions": { + "moduleResolution": "bundler", "outDir": "./out-tsc/spec", "types": ["jasmine"] }, From 2add6bb8a86bd0c099360631e82b353a46391798 Mon Sep 17 00:00:00 2001 From: Eric Joanis Date: Fri, 3 Jul 2026 11:22:24 -0400 Subject: [PATCH 2/2] Revert "ci: disable test:once studio-web not compat with ng21" This reverts commit fe88aef78c6037d4d8a3dff3ec1004435c435228. --- .github/workflows/deploy.yml | 7 +++---- .github/workflows/dev-preview.yml | 6 +++--- .github/workflows/end-to-end-tests.yml | 9 ++++----- .github/workflows/windows-tests.yml | 8 ++++---- 4 files changed, 14 insertions(+), 16 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index f11395e14..cb51a8698 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -26,10 +26,9 @@ jobs: # create the bundles required for studio-web # TODO: stop updating the bundle, keep the published one. npx nx bundle web-component - # Not compatible with Angular 21 - #- name: Specs Test - # run: | - # npx nx test:once studio-web + - name: Specs Test + run: | + npx nx test:once studio-web - name: Build run: | npx nx build studio-web --configuration=production diff --git a/.github/workflows/dev-preview.yml b/.github/workflows/dev-preview.yml index 17eaa9313..a0a7e47a7 100644 --- a/.github/workflows/dev-preview.yml +++ b/.github/workflows/dev-preview.yml @@ -26,9 +26,9 @@ jobs: run: | # create the bundles required for studio-web npx nx bundle web-component - #- name: Test - # run: | - # npx nx test:once studio-web + - name: Test + run: | + npx nx test:once studio-web - name: Build run: | sed -r -i 's:readalong-studio.mothertongues.org/:readalong-studio.mothertongues.org/dev/:g' packages/studio-web/src/environments/environment.prod.ts diff --git a/.github/workflows/end-to-end-tests.yml b/.github/workflows/end-to-end-tests.yml index 1eb059972..9607bd12b 100644 --- a/.github/workflows/end-to-end-tests.yml +++ b/.github/workflows/end-to-end-tests.yml @@ -43,11 +43,10 @@ jobs: wait-on: sleep 15 # there is no reliable URL to wait for... command: npx nx test:once web-component - # Disabled since not compatible with Angular 21 - #- name: Ng spec tests for studio-web - # run: | - # npx nx build web-component - # npx nx test:once studio-web + - name: Ng spec tests for studio-web + run: | + npx nx build web-component + npx nx test:once studio-web - name: Check that i18n and l10n are up to date run: | diff --git a/.github/workflows/windows-tests.yml b/.github/workflows/windows-tests.yml index a7e41c530..8e00e2ae5 100644 --- a/.github/workflows/windows-tests.yml +++ b/.github/workflows/windows-tests.yml @@ -20,10 +20,10 @@ jobs: - run: npm install -g npm@latest - run: npm ci --verbose - run: npx update-browserslist-db@latest - #- name: Ng test for studio-web - # run: | - # npx nx build web-component - # npx nx test:once studio-web + - name: Ng test for studio-web + run: | + npx nx build web-component + npx nx test:once studio-web - name: Cypress run for web-component uses: cypress-io/github-action@783cb3f07983868532cabaedaa1e6c00ff4786a8 # v7.1.9