Skip to content

Commit 6a64bbe

Browse files
feat: update to Angular 20 (#530)
BREAKING CHANGE: The angular minimum version has changed. BEFORE: Angular 17,18,19 were supported. AFTER: Angular 20 is supported: - TestBed.get is removed
1 parent 3cb2469 commit 6a64bbe

File tree

7 files changed

+30
-33
lines changed

7 files changed

+30
-33
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222

2323
strategy:
2424
matrix:
25-
node-version: ${{ fromJSON((github.ref == 'refs/heads/main' || github.ref == 'refs/heads/beta') && '[22]' || '[18, 20, 22]') }}
25+
node-version: ${{ fromJSON((github.ref == 'refs/heads/main' || github.ref == 'refs/heads/beta') && '[22]' || '[20, 22, 24]') }}
2626
os: ${{ fromJSON((github.ref == 'refs/heads/main' || github.ref == 'refs/heads/beta') && '["ubuntu-latest"]' || '["ubuntu-latest", "windows-latest"]') }}
2727
runs-on: ${{ matrix.os }}
2828

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,4 @@ yarn.lock
4646
Thumbs.db
4747
.cursor/rules/nx-rules.mdc
4848
.github/instructions/nx.instructions.md
49+
.history

apps/example-app-karma/src/app/issues/issue-491.spec.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Component } from '@angular/core';
22
import { Router } from '@angular/router';
3-
import { render, screen, waitForElementToBeRemoved } from '@testing-library/angular';
3+
import { render, screen } from '@testing-library/angular';
44
import userEvent from '@testing-library/user-event';
55

66
it('test click event with router.navigate', async () => {
@@ -31,8 +31,6 @@ it('test click event with router.navigate', async () => {
3131

3232
await user.click(screen.getByRole('button', { name: 'submit' }));
3333

34-
await waitForElementToBeRemoved(() => screen.queryByRole('heading', { name: 'Login' }));
35-
3634
expect(await screen.findByRole('heading', { name: 'Logged In' })).toBeVisible();
3735
});
3836

package.json

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@
2727
"prepare": "git config core.hookspath .githooks"
2828
},
2929
"dependencies": {
30-
"@angular/animations": "19.2.14",
31-
"@angular/cdk": "19.2.18",
32-
"@angular/common": "19.2.14",
33-
"@angular/compiler": "19.2.14",
34-
"@angular/core": "19.2.14",
35-
"@angular/material": "19.2.18",
36-
"@angular/platform-browser": "19.2.14",
37-
"@angular/platform-browser-dynamic": "19.2.14",
38-
"@angular/router": "19.2.14",
30+
"@angular/animations": "20.0.0",
31+
"@angular/cdk": "20.0.0",
32+
"@angular/common": "20.0.0",
33+
"@angular/compiler": "20.0.0",
34+
"@angular/core": "20.0.0",
35+
"@angular/material": "20.0.0",
36+
"@angular/platform-browser": "20.0.0",
37+
"@angular/platform-browser-dynamic": "20.0.0",
38+
"@angular/router": "20.0.0",
3939
"@ngrx/store": "19.0.0",
4040
"@nx/angular": "21.1.2",
4141
"@testing-library/dom": "^10.4.0",
@@ -44,26 +44,26 @@
4444
"zone.js": "^0.15.0"
4545
},
4646
"devDependencies": {
47-
"@angular-devkit/build-angular": "19.2.9",
48-
"@angular-devkit/core": "19.2.9",
49-
"@angular-devkit/schematics": "19.2.9",
47+
"@angular-devkit/build-angular": "20.0.0",
48+
"@angular-devkit/core": "20.0.0",
49+
"@angular-devkit/schematics": "20.0.0",
5050
"@angular-eslint/builder": "19.2.0",
5151
"@angular-eslint/eslint-plugin": "19.2.0",
5252
"@angular-eslint/eslint-plugin-template": "19.2.0",
5353
"@angular-eslint/schematics": "19.2.0",
5454
"@angular-eslint/template-parser": "19.2.0",
55-
"@angular/cli": "~19.2.0",
56-
"@angular/compiler-cli": "19.2.14",
57-
"@angular/forms": "19.2.14",
58-
"@angular/language-service": "19.2.14",
55+
"@angular/cli": "~20.0.0",
56+
"@angular/compiler-cli": "20.0.0",
57+
"@angular/forms": "20.0.0",
58+
"@angular/language-service": "20.0.0",
5959
"@eslint/eslintrc": "^2.1.1",
6060
"@nx/eslint": "21.1.2",
6161
"@nx/eslint-plugin": "21.1.2",
6262
"@nx/jest": "21.1.2",
6363
"@nx/node": "21.1.2",
6464
"@nx/plugin": "21.1.2",
6565
"@nx/workspace": "21.1.2",
66-
"@schematics/angular": "19.2.9",
66+
"@schematics/angular": "20.0.0",
6767
"@testing-library/jasmine-dom": "^1.3.3",
6868
"@testing-library/jest-dom": "^6.6.3",
6969
"@testing-library/user-event": "^14.5.2",
@@ -91,7 +91,7 @@
9191
"karma-jasmine-html-reporter": "2.0.0",
9292
"lint-staged": "^15.3.0",
9393
"ng-mocks": "^14.13.1",
94-
"ng-packagr": "19.2.2",
94+
"ng-packagr": "20.0.0",
9595
"nx": "21.1.2",
9696
"postcss": "^8.4.49",
9797
"postcss-import": "14.1.0",
@@ -102,7 +102,7 @@
102102
"semantic-release": "^24.2.1",
103103
"ts-jest": "29.1.0",
104104
"ts-node": "10.9.1",
105-
"typescript": "5.7.3",
105+
"typescript": "5.8.2",
106106
"typescript-eslint": "^8.19.0"
107107
}
108108
}

projects/testing-library/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@
2929
"migrations": "./schematics/migrations/migrations.json"
3030
},
3131
"peerDependencies": {
32-
"@angular/animations": ">= 17.0.0",
33-
"@angular/common": ">= 17.0.0",
34-
"@angular/platform-browser": ">= 17.0.0",
35-
"@angular/router": ">= 17.0.0",
36-
"@angular/core": ">= 17.0.0",
32+
"@angular/animations": ">= 20.0.0",
33+
"@angular/common": ">= 20.0.0",
34+
"@angular/platform-browser": ">= 20.0.0",
35+
"@angular/router": ">= 20.0.0",
36+
"@angular/core": ">= 20.0.0",
3737
"@testing-library/dom": "^10.0.0"
3838
},
3939
"dependencies": {

projects/testing-library/src/lib/testing-library.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ import {
4040
type SubscribedOutput<T> = readonly [key: keyof T, callback: (v: any) => void, subscription: OutputRefSubscription];
4141

4242
const mountedFixtures = new Set<ComponentFixture<any>>();
43-
const safeInject = TestBed.inject || TestBed.get;
4443

4544
export async function render<ComponentType>(
4645
component: Type<ComponentType>,
@@ -126,8 +125,8 @@ export async function render<SutType, WrapperType = SutType>(
126125

127126
const componentContainer = createComponentFixture(sut, wrapper);
128127

129-
const zone = safeInject(NgZone);
130-
const router = safeInject(Router);
128+
const zone = TestBed.inject(NgZone);
129+
const router = TestBed.inject(Router);
131130
const _navigate = async (elementOrPath: Element | string, basePath = ''): Promise<boolean> => {
132131
const href = typeof elementOrPath === 'string' ? elementOrPath : elementOrPath.getAttribute('href');
133132
const [path, params] = (basePath + href).split('?');
@@ -338,7 +337,7 @@ export async function render<SutType, WrapperType = SutType>(
338337

339338
async function createComponent<SutType>(component: Type<SutType>): Promise<ComponentFixture<SutType>> {
340339
/* Make sure angular application is initialized before creating component */
341-
await safeInject(ApplicationInitStatus).donePromise;
340+
await TestBed.inject(ApplicationInitStatus).donePromise;
342341
return TestBed.createComponent(component);
343342
}
344343

projects/testing-library/tests/defer-blocks.spec.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ test('renders a defer block in different states using DeferBlockBehavior.Playthr
3333
deferBlockBehavior: DeferBlockBehavior.Playthrough,
3434
});
3535

36-
expect(await screen.findByText(/loading/i)).toBeInTheDocument();
3736
expect(await screen.findByText(/Defer block content/i)).toBeInTheDocument();
3837
});
3938

0 commit comments

Comments
 (0)