Skip to content

Commit 44167af

Browse files
committed
feat: update to Angular 21 (and switch to Vitest)
1 parent db204fb commit 44167af

File tree

88 files changed

+350
-436
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+350
-436
lines changed

.browserslistrc

Lines changed: 0 additions & 9 deletions
This file was deleted.

angular.json

Lines changed: 21 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"prefix": "lib",
1919
"architect": {
2020
"build": {
21-
"builder": "@angular-devkit/build-angular:ng-packagr",
21+
"builder": "@angular/build:ng-packagr",
2222
"options": {
2323
"project": "projects/testing-library/ng-package.json"
2424
},
@@ -33,9 +33,9 @@
3333
"defaultConfiguration": "production"
3434
},
3535
"test": {
36-
"builder": "@angular-builders/jest:run",
36+
"builder": "@angular/build:unit-test",
3737
"options": {
38-
"configPath": "projects/testing-library/jest.config.ts"
38+
"setupFiles": ["projects/testing-library/test-setup.ts"]
3939
}
4040
},
4141
"lint": {
@@ -53,16 +53,17 @@
5353
"prefix": "app",
5454
"architect": {
5555
"build": {
56-
"builder": "@angular-devkit/build-angular:browser",
56+
"builder": "@angular/build:application",
5757
"options": {
58-
"outputPath": "dist/apps/example-app",
58+
"outputPath": {
59+
"base": "dist/apps/example-app"
60+
},
5961
"index": "apps/example-app/src/index.html",
60-
"main": "apps/example-app/src/main.ts",
61-
"polyfills": "apps/example-app/src/polyfills.ts",
6262
"tsConfig": "apps/example-app/tsconfig.app.json",
6363
"assets": ["apps/example-app/src/favicon.ico", "apps/example-app/src/assets"],
64-
"styles": ["apps/example-app/src/styles.css"],
65-
"scripts": []
64+
"styles": [],
65+
"scripts": [],
66+
"browser": "apps/example-app/src/main.ts"
6667
},
6768
"configurations": {
6869
"production": {
@@ -75,9 +76,7 @@
7576
"outputHashing": "all"
7677
},
7778
"development": {
78-
"buildOptimizer": false,
7979
"optimization": false,
80-
"vendorChunk": true,
8180
"extractLicenses": false,
8281
"sourceMap": true,
8382
"namedChunks": true
@@ -86,7 +85,7 @@
8685
"defaultConfiguration": "production"
8786
},
8887
"serve": {
89-
"builder": "@angular-devkit/build-angular:dev-server",
88+
"builder": "@angular/build:dev-server",
9089
"configurations": {
9190
"production": {
9291
"buildTarget": "example-app:build:production"
@@ -97,16 +96,10 @@
9796
},
9897
"defaultConfiguration": "development"
9998
},
100-
"extract-i18n": {
101-
"builder": "@angular-devkit/build-angular:extract-i18n",
102-
"options": {
103-
"buildTarget": "example-app:build"
104-
}
105-
},
10699
"test": {
107-
"builder": "@angular-builders/jest:run",
100+
"builder": "@angular/build:unit-test",
108101
"options": {
109-
"configPath": "apps/example-app/jest.config.ts"
102+
"setupFiles": ["apps/example-app/test-setup.ts"]
110103
}
111104
},
112105
"lint": {
@@ -124,15 +117,17 @@
124117
"prefix": "app",
125118
"architect": {
126119
"build": {
127-
"builder": "@angular-devkit/build-angular:browser",
120+
"builder": "@angular/build:application",
128121
"options": {
129-
"outputPath": "dist/apps/example-app-karma",
122+
"outputPath": {
123+
"base": "dist/apps/example-app-karma"
124+
},
130125
"index": "apps/example-app-karma/src/index.html",
131-
"main": "apps/example-app-karma/src/main.ts",
132126
"tsConfig": "apps/example-app-karma/tsconfig.app.json",
133127
"assets": ["apps/example-app-karma/src/favicon.ico", "apps/example-app-karma/src/assets"],
134128
"styles": [],
135-
"scripts": []
129+
"scripts": [],
130+
"browser": "apps/example-app-karma/src/main.ts"
136131
},
137132
"configurations": {
138133
"production": {
@@ -145,9 +140,7 @@
145140
"outputHashing": "all"
146141
},
147142
"development": {
148-
"buildOptimizer": false,
149143
"optimization": false,
150-
"vendorChunk": true,
151144
"extractLicenses": false,
152145
"sourceMap": true,
153146
"namedChunks": true
@@ -156,7 +149,7 @@
156149
"defaultConfiguration": "production"
157150
},
158151
"serve": {
159-
"builder": "@angular-devkit/build-angular:dev-server",
152+
"builder": "@angular/build:dev-server",
160153
"configurations": {
161154
"production": {
162155
"buildTarget": "example-app-karma:build:production"
@@ -168,7 +161,7 @@
168161
"defaultConfiguration": "development"
169162
},
170163
"test": {
171-
"builder": "@angular-devkit/build-angular:karma",
164+
"builder": "@angular/build:karma",
172165
"options": {
173166
"main": "apps/example-app-karma/src/test.ts",
174167
"tsConfig": "apps/example-app-karma/tsconfig.spec.json",

apps/example-app-karma/karma.conf.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,7 @@ module.exports = function (config) {
55
config.set({
66
basePath: '',
77
frameworks: ['jasmine', '@angular-devkit/build-angular'],
8-
plugins: [
9-
require('karma-jasmine'),
10-
require('karma-chrome-launcher'),
11-
require('@angular-devkit/build-angular/plugins/karma'),
12-
],
8+
plugins: [require('karma-jasmine'), require('karma-chrome-launcher')],
139
client: {
1410
jasmine: {
1511
// you can add configuration options for Jasmine here

apps/example-app-karma/src/app/examples/login-form.spec.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { Component, inject } from '@angular/core';
22
import { FormBuilder, FormControl, FormGroup, Validators, ReactiveFormsModule } from '@angular/forms';
33
import userEvent from '@testing-library/user-event';
44
import { render, screen } from '@testing-library/angular';
5-
import { NgIf } from '@angular/common';
65

76
it('should create a component with inputs and a button to submit', async () => {
87
await render(LoginComponent);
@@ -31,15 +30,19 @@ it('should display invalid message and submit button must be disabled', async ()
3130
@Component({
3231
selector: 'atl-login',
3332
standalone: true,
34-
imports: [ReactiveFormsModule, NgIf],
33+
imports: [ReactiveFormsModule],
3534
template: `
3635
<h1>Login</h1>
3736
3837
<form [formGroup]="form" (submit)="onSubmit(form)">
3938
<input type="email" aria-label="email" formControlName="email" />
40-
<div *ngIf="email.invalid && (email.dirty || email.touched)" role="alert">Email is invalid</div>
39+
@if (email.invalid && (email.dirty || email.touched)) {
40+
<div role="alert">Email is invalid</div>
41+
}
4142
<input type="password" aria-label="password" formControlName="password" />
42-
<div *ngIf="password.invalid && (password.dirty || password.touched)" role="alert">Password is invalid</div>
43+
@if (password.invalid && (password.dirty || password.touched)) {
44+
<div role="alert">Password is invalid</div>
45+
}
4346
<button type="submit" aria-label="submit" [disabled]="form.invalid">Submit</button>
4447
</form>
4548
`,

apps/example-app-karma/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"extends": "../../tsconfig.base.json",
2+
"extends": "../../tsconfig.json",
33
"files": [],
44
"include": [],
55
"compilerOptions": {

apps/example-app-karma/tsconfig.spec.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"extends": "./tsconfig.json",
33
"compilerOptions": {
44
"outDir": "./out-tsc/spec",
5-
"types": ["jasmine", "node", "@testing-library/jasmine-dom"],
5+
"types": ["node", "@testing-library/jasmine-dom"],
66
"target": "ES2022",
77
"useDefineForClassFields": false
88
},

apps/example-app/jest.config.ts

Lines changed: 0 additions & 29 deletions
This file was deleted.

apps/example-app/src/app/examples/00-single-component.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { test, expect } from 'vitest';
12
import { render, screen } from '@testing-library/angular';
23
import userEvent from '@testing-library/user-event';
34

apps/example-app/src/app/examples/01-nested-component.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { test, expect } from 'vitest';
12
import { render, screen } from '@testing-library/angular';
23
import userEvent from '@testing-library/user-event';
34

apps/example-app/src/app/examples/02-input-output.spec.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
import { test, expect, vi } from 'vitest';
12
import { render, screen } from '@testing-library/angular';
23
import userEvent from '@testing-library/user-event';
34

45
import { InputOutputComponent } from './02-input-output';
56

67
test('is possible to set input and listen for output', async () => {
78
const user = userEvent.setup();
8-
const sendValue = jest.fn();
9+
const sendValue = vi.fn();
910

1011
await render(InputOutputComponent, {
1112
inputs: {
@@ -34,7 +35,7 @@ test('is possible to set input and listen for output', async () => {
3435

3536
test.skip('is possible to set input and listen for output with the template syntax', async () => {
3637
const user = userEvent.setup();
37-
const sendSpy = jest.fn();
38+
const sendSpy = vi.fn();
3839

3940
await render('<atl-fixture [value]="47" (sendValue)="sendValue($event)" />', {
4041
imports: [InputOutputComponent],
@@ -61,7 +62,7 @@ test.skip('is possible to set input and listen for output with the template synt
6162

6263
test('is possible to set input and listen for output (deprecated)', async () => {
6364
const user = userEvent.setup();
64-
const sendValue = jest.fn();
65+
const sendValue = vi.fn();
6566

6667
await render(InputOutputComponent, {
6768
inputs: {
@@ -92,7 +93,7 @@ test('is possible to set input and listen for output (deprecated)', async () =>
9293

9394
test('is possible to set input and listen for output with the template syntax (deprecated)', async () => {
9495
const user = userEvent.setup();
95-
const sendSpy = jest.fn();
96+
const sendSpy = vi.fn();
9697

9798
await render('<atl-fixture [value]="47" (sendValue)="sendValue($event)" />', {
9899
imports: [InputOutputComponent],

0 commit comments

Comments
 (0)