Skip to content

Commit b064ea7

Browse files
authored
Angular 17 (#633)
* feat: 🎸 upgrade to Angular 17 Upgrade packages and dependencies BREAKING CHANGE: 🧨 The library now requires a minimum version of Angular 17.0.0 ✅ Closes: #631 * feat: 🎸 upgrade to Angular 17 Added a wrapper for Angular 17 TestBed.flushEffects() ✅ Closes: #631
1 parent 9478289 commit b064ea7

File tree

6 files changed

+3611
-3295
lines changed

6 files changed

+3611
-3295
lines changed

‎README.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ The `createComponent()` method returns an instance of `Spectator` which exposes
209209
- `element` - The tested component's native element
210210
- `debugElement` - The tested fixture's debug element
211211

212+
- `flushEffects()` - Provides a wrapper for `TestBed.flushEffects()`
212213
- `inject()` - Provides a wrapper for `TestBed.inject()`:
213214
```ts
214215
const service = spectator.inject(QueryService);
@@ -1008,7 +1009,7 @@ it('should call the weather api in the constructor', () => {
10081009
{ provide: WeatherDataApi, useValue: weatherService }
10091010
]
10101011
});
1011-
1012+
10121013
expect(weatherService.getWeatherData).toHaveBeenCalled();
10131014
});
10141015
```
@@ -1219,7 +1220,7 @@ expect('.zippy__content').toHaveClass(['class-b', 'class-a'], { strict: false })
12191220

12201221
// Note that toHaveText only looks for the existence of a string, not if the string is exactly the same. If you want to verify that the string is completely the same, use toHaveExactText.
12211222
// Note that if you want to verify that the string is completely the same, but trimmed first, use toHaveExactTrimmedText.
1222-
// Note that if you pass multiple values, Spectator checks the text of each array element against the index of the element found.
1223+
// Note that if you pass multiple values, Spectator checks the text of each array element against the index of the element found.
12231224
expect('.zippy__content').toHaveText('Content');
12241225
expect('.zippy__content').toHaveText(['Content A', 'Content B']);
12251226
expect('.zippy__content').toHaveText((text) => text.includes('..'));
@@ -1288,7 +1289,7 @@ The `spectator` schematics extend the default `@schematics/angular` collection.
12881289
12891290
## Working Spectator & Jest Sample Repo and Karma Comparison
12901291
1291-
The [examples in Karma]((https://stackblitz.com/angular/pmqopjovvvb?file=src%2Fapp%2Fapp.component.html)) from Angular docs [testing developer guide](https://angular.io/guide/testing) has been reproduced in Spectator and Jest.
1292+
The [examples in Karma]((https://stackblitz.com/angular/pmqopjovvvb?file=src%2Fapp%2Fapp.component.html)) from Angular docs [testing developer guide](https://angular.io/guide/testing) has been reproduced in Spectator and Jest.
12921293
(For convenience, [this is the local version](https://github.com/muratkeremozcan/books/tree/master/Angular_with_Typescript/angular-unit-testing-with-Karma) of the Karma examples.)
12931294
12941295
The Spectator & Jest version can be accessed [here](https://github.com/muratkeremozcan/angular-playground).

‎package.json

+38-37
Original file line numberDiff line numberDiff line change
@@ -30,59 +30,60 @@
3030
"release:dry": "cd projects/spectator && standard-version --infile ../../CHANGELOG.md --dry-run"
3131
},
3232
"devDependencies": {
33-
"@angular-builders/jest": "^16.0.0",
34-
"@angular-devkit/build-angular": "^16.0.0",
35-
"@angular-devkit/schematics": "^16.0.0",
36-
"@angular-eslint/builder": "16.0.1",
37-
"@angular-eslint/eslint-plugin": "16.0.1",
38-
"@angular-eslint/eslint-plugin-template": "16.0.1",
39-
"@angular-eslint/schematics": "16.0.1",
40-
"@angular-eslint/template-parser": "16.0.1",
41-
"@angular/animations": "^16.0.0",
42-
"@angular/cdk": "^16.0.0",
43-
"@angular/cli": "^16.0.0",
44-
"@angular/common": "^16.0.0",
45-
"@angular/compiler": "^16.0.0",
46-
"@angular/compiler-cli": "^16.0.0",
47-
"@angular/core": "^16.0.0",
48-
"@angular/forms": "^16.0.0",
49-
"@angular/language-service": "^16.0.0",
50-
"@angular/platform-browser": "^16.0.0",
51-
"@angular/platform-browser-dynamic": "^16.0.0",
52-
"@angular/router": "16.0.0",
33+
"@angular-builders/jest": "^17.0.0",
34+
"@angular-devkit/build-angular": "^17.0.6",
35+
"@angular-devkit/schematics": "^17.0.6",
36+
"@angular-eslint/builder": "17.1.1",
37+
"@angular-eslint/eslint-plugin": "17.1.1",
38+
"@angular-eslint/eslint-plugin-template": "17.1.1",
39+
"@angular-eslint/schematics": "17.1.1",
40+
"@angular-eslint/template-parser": "17.1.1",
41+
"@angular/animations": "^17.0.6",
42+
"@angular/cdk": "^17.0.3",
43+
"@angular/cli": "^17.0.6",
44+
"@angular/common": "^17.0.6",
45+
"@angular/compiler": "^17.0.6",
46+
"@angular/compiler-cli": "^17.0.6",
47+
"@angular/core": "^17.0.6",
48+
"@angular/forms": "^17.0.6",
49+
"@angular/language-service": "^17.0.6",
50+
"@angular/platform-browser": "^17.0.6",
51+
"@angular/platform-browser-dynamic": "^17.0.6",
52+
"@angular/router": "17.0.6",
5353
"@commitlint/cli": "17.3.0",
5454
"@commitlint/config-angular": "17.3.0",
5555
"@commitlint/config-conventional": "17.3.0",
56-
"@types/jasmine": "3.8.1",
57-
"@types/jest": "29.5.2",
58-
"@types/node": "18.16.5",
59-
"@typescript-eslint/eslint-plugin": "^5.59.2",
60-
"@typescript-eslint/parser": "^5.59.2",
56+
"@types/jasmine": "5.1.4",
57+
"@types/jest": "29.5.11",
58+
"@types/node": "20.10.4",
59+
"@typescript-eslint/eslint-plugin": "^6.13.2",
60+
"@typescript-eslint/parser": "^6.13.2",
6161
"all-contributors-cli": "^6.19.0",
6262
"core-js": "^3.9.1",
6363
"cross-env": "^5.1.4",
6464
"cz-conventional-changelog": "^3.3.0",
65-
"eslint": "^8.39.0",
65+
"eslint": "^8.55.0",
6666
"git-cz": "^4.7.6",
6767
"helpful-decorators": "^2.1.0",
6868
"husky": "^8.0.2",
69-
"jasmine-core": "3.8.0",
69+
"jasmine-core": "5.1.1",
7070
"jasmine-spec-reporter": "7.0.0",
71-
"jest": "29.5.0",
72-
"jest-preset-angular": "13.1.1",
73-
"karma": "6.3.4",
74-
"karma-chrome-launcher": "3.1.0",
71+
"jest": "29.7.0",
72+
"jest-preset-angular": "13.1.4",
73+
"karma": "6.4.2",
74+
"karma-chrome-launcher": "3.2.0",
7575
"karma-coverage-istanbul-reporter": "3.0.3",
76-
"karma-jasmine": "4.0.1",
77-
"karma-jasmine-html-reporter": "1.7.0",
76+
"karma-jasmine": "5.1.0",
77+
"karma-jasmine-html-reporter": "2.1.0",
7878
"lint-staged": "^13.1.0",
79-
"ng-packagr": "16.0.0",
79+
"ng-packagr": "17.0.2",
8080
"prettier": "2.3.2",
81-
"rxjs": "6.6.3",
81+
"rxjs": "7.8.1",
8282
"standard-version": "^9.1.0",
8383
"ts-node": "10.1.0",
84-
"typescript": "5.0.4",
85-
"zone.js": "0.13.0"
84+
"tslib": "^2.6.2",
85+
"typescript": "5.2.2",
86+
"zone.js": "0.14.2"
8687
},
8788
"config": {
8889
"commitizen": {

‎projects/spectator/package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@
2626
"@testing-library/dom": "^8.11.0",
2727
"jquery": "3.6.4",
2828
"replace-in-file": "6.2.0",
29-
"tslib": "^2.1.0"
29+
"tslib": "^2.6.2"
3030
},
3131
"peerDependencies": {
32-
"@angular/common": ">= 16.0.0",
33-
"@angular/router": ">= 16.0.0",
34-
"@angular/animations": ">= 16.0.0"
32+
"@angular/common": ">= 17.0.0",
33+
"@angular/router": ">= 17.0.0",
34+
"@angular/animations": ">= 17.0.0"
3535
},
3636
"schematics": "./schematics/collection.json"
3737
}

‎projects/spectator/src/lib/base/base-spectator.ts

+7
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,11 @@ export abstract class BaseSpectator {
1010
public inject<T>(token: Token<T>): SpyObject<T> {
1111
return TestBed.inject ? TestBed.inject(token) : TestBed.get(token);
1212
}
13+
14+
/**
15+
* Execute any pending effects.
16+
*/
17+
public flushEffects(): void {
18+
TestBed.flushEffects();
19+
}
1320
}

‎projects/spectator/tsconfig.lib.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
"declaration": true,
77
"inlineSources": true,
88
"typeRoots": [
9-
"./typings"
9+
"./typings",
10+
"../../node_modules/@types"
1011
],
1112
"types": [
1213
"jasmine",

0 commit comments

Comments
 (0)