Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 306546e

Browse files
feat: upgrade to Angular 10 (testing-library#119)
BREAKING CHANGE: - fire events (e.g. `click`, `input`, `change`) are removed from the render result, import `fireEvent` directly from `@testing-library/angular` (as an example take a look at http://github.com/testing-library/angular-testing-library/blob/master/apps/example-app/app/examples/03-forms.spec.ts#L2) - `waitFor` and `waitForElementToBeRemoved` are removed from the render result, import them directly from `@testing-library/angular` - custom user events are removed, use the `@testing-library/user-event` package (testing-library.com/docs/ecosystem-user-event) - `selectOptions` now selects the option based on its value, not via the text of the select option
1 parent 66e98b9 commit 306546e

32 files changed

+3413
-5394
lines changed
File renamed without changes.

‎apps/example-app/tsconfig.json

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

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

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

‎package.json

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -20,52 +20,52 @@
2020
"semantic-release": "semantic-release"
2121
},
2222
"dependencies": {
23-
"@angular/animations": "^9.0.3",
24-
"@angular/cdk": "^9.1.0",
25-
"@angular/common": "^9.0.3",
26-
"@angular/compiler": "^9.0.3",
27-
"@angular/core": "^9.0.3",
28-
"@angular/forms": "^9.0.3",
29-
"@angular/material": "^9.1.0",
30-
"@angular/platform-browser": "^9.0.3",
31-
"@angular/platform-browser-dynamic": "^9.0.3",
32-
"@angular/router": "^9.0.3",
33-
"@ngrx/store": "^9.0.0-rc.0",
23+
"@angular/animations": "^10.0.0",
24+
"@angular/cdk": "^10.0.0",
25+
"@angular/common": "^10.0.0",
26+
"@angular/compiler": "^10.0.0",
27+
"@angular/core": "^10.0.0",
28+
"@angular/forms": "^10.0.0",
29+
"@angular/material": "^10.0.0",
30+
"@angular/platform-browser": "^10.0.0",
31+
"@angular/platform-browser-dynamic": "^10.0.0",
32+
"@angular/router": "^10.0.0",
33+
"@ngrx/store": "^9.2.0",
3434
"@nrwl/angular": "^9.4.5",
35-
"@phenomnomnominal/tsquery": "^3.0.0",
36-
"@testing-library/dom": "^7.9.0",
37-
"@testing-library/user-event": "^11.0.0",
38-
"core-js": "^3.1.3",
39-
"rxjs": "^6.5.4",
40-
"tslib": "^1.11.1",
41-
"tslint": "^5.16.0",
42-
"zone.js": "~0.10.2"
35+
"@phenomnomnominal/tsquery": "^4.1.0",
36+
"@testing-library/dom": "^7.18.1",
37+
"@testing-library/user-event": "^12.0.11",
38+
"core-js": "^3.6.5",
39+
"rxjs": "^6.5.5",
40+
"tslib": "^2.0.0",
41+
"tslint": "~6.1.0",
42+
"zone.js": "~0.10.3"
4343
},
4444
"devDependencies": {
45-
"@angular-devkit/build-angular": "~0.900.3",
46-
"@angular-devkit/build-ng-packagr": "~0.900.3",
47-
"@angular/cli": "~9.0.3",
48-
"@angular/compiler-cli": "^9.0.3",
49-
"@angular/language-service": "^9.0.3",
45+
"@angular-devkit/build-angular": "~0.1000.0",
46+
"@angular-devkit/build-ng-packagr": "~0.1000.0",
47+
"@angular/cli": "~10.0.0",
48+
"@angular/compiler-cli": "^10.0.0",
49+
"@angular/language-service": "^10.0.0",
5050
"@nrwl/jest": "^9.4.5",
5151
"@nrwl/node": "^9.4.5",
5252
"@nrwl/nx-plugin": "^9.4.5",
5353
"@nrwl/workspace": "^9.4.5",
54-
"@testing-library/jest-dom": "^5.9.0",
55-
"@types/jest": "~24.0.11",
56-
"@types/node": "^14.0.11",
57-
"codelyzer": "^5.1.2",
58-
"cpy-cli": "^3.1.0",
54+
"@testing-library/jest-dom": "^5.11.0",
55+
"@types/jest": "~26.0.3",
56+
"@types/node": "^14.0.14",
57+
"codelyzer": "^5.2.2",
58+
"cpy-cli": "^3.1.1",
5959
"husky": "^4.2.5",
60-
"jest": "^25.5.4",
61-
"jest-preset-angular": "^8.2.0",
62-
"lint-staged": "^10.2.9",
63-
"ng-packagr": "^9.0.0",
60+
"jest": "^26.1.0",
61+
"jest-preset-angular": "^8.2.1",
62+
"lint-staged": "^10.2.11",
63+
"ng-packagr": "^10.0.0",
6464
"prettier": "^2.0.5",
6565
"rimraf": "^3.0.2",
66-
"semantic-release": "^17.0.2",
67-
"ts-jest": "^26.1.0",
66+
"semantic-release": "^17.1.1",
67+
"ts-jest": "^26.1.1",
6868
"ts-node": "~8.10.2",
69-
"typescript": "~3.7.5"
69+
"typescript": "~3.9.5"
7070
}
71-
}
71+
}

‎projects/jest-utils/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,8 @@
2626
},
2727
"publishConfig": {
2828
"access": "public"
29+
},
30+
"dependencies": {
31+
"tslib": "^2.0.0"
2932
}
3033
}

‎projects/jest-utils/tests/create-mock.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Component } from '@angular/core';
22
import { TestBed } from '@angular/core/testing';
33

44
import { createMock, provideMock, Mock } from '../src/public_api';
5-
import { render } from '../../testing-library/src/public_api';
5+
import { render,fireEvent } from '../../testing-library/src/public_api';
66

77
class FixtureService {
88
constructor(private foo: string, public bar: string) {}
@@ -30,22 +30,22 @@ it('mocks all functions', () => {
3030
});
3131

3232
it('provides a mock service', async () => {
33-
const { click,getByText } = await render(FixtureComponent, {
33+
const { getByText } = await render(FixtureComponent, {
3434
providers: [provideMock(FixtureService)],
3535
});
3636
const service = TestBed.inject(FixtureService);
3737

38-
click(getByText('Print'));
38+
fireEvent.click(getByText('Print'));
3939
expect(service.print).toHaveBeenCalledTimes(1);
4040
});
4141

4242
it('is possible to write a mock implementation', async (done) => {
43-
const { click,getByText } = await render(FixtureComponent, {
43+
const { getByText } = await render(FixtureComponent, {
4444
providers: [provideMock(FixtureService)],
4545
});
4646

4747
const service = TestBed.inject(FixtureService) as Mock<FixtureService>;
4848
service.print.mockImplementation(() => done());
4949

50-
click(getByText('Print'));
50+
fireEvent.click(getByText('Print'));
5151
});

‎projects/jest-utils/tsconfig.lib.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"extends": "../../tsconfig.json",
2+
"extends": "../../tsconfig.base.json",
33
"compilerOptions": {
44
"outDir": "../../out-tsc/lib",
55
"target": "es2015",

‎projects/jest-utils/tsconfig.spec.json

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

‎projects/testing-library/package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,16 @@
2222
},
2323
"homepage": "https://github.com/testing-library/angular-testing-library#readme",
2424
"peerDependencies": {
25-
"@angular/common": "^9.0.0",
26-
"@angular/platform-browser": "^9.0.0",
27-
"@angular/animations": "^9.0.0",
28-
"@angular/router": "^9.0.0",
29-
"@angular/core": "^9.0.0"
25+
"@angular/common": "^10.0.0",
26+
"@angular/platform-browser": "^10.0.0",
27+
"@angular/animations": "^10.0.0",
28+
"@angular/router": "^10.0.0",
29+
"@angular/core": "^10.0.0"
3030
},
3131
"dependencies": {
32-
"@testing-library/dom": "^7.9.0",
33-
"@testing-library/user-event": "^8.1.0",
32+
"@testing-library/dom": "^7.18.1",
3433
"@phenomnomnominal/tsquery": "^3.0.0",
34+
"tslib": "^2.0.0",
3535
"tslint": "^5.16.0"
3636
},
3737
"publishConfig": {

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

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,11 @@
11
import { Type, DebugElement } from '@angular/core';
22
import { ComponentFixture } from '@angular/core/testing';
33
import { Routes } from '@angular/router';
4-
import {
5-
BoundFunction,
6-
FireObject,
7-
Queries,
8-
queries,
9-
waitFor,
10-
waitForElementToBeRemoved,
11-
Config as dtlConfig,
12-
} from '@testing-library/dom';
13-
import { UserEvents } from './user-events';
4+
import { BoundFunction, Queries, queries, Config as dtlConfig } from '@testing-library/dom';
145
import { OptionsReceived } from 'pretty-format';
156

167
export type RenderResultQueries<Q extends Queries = typeof queries> = { [P in keyof Q]: BoundFunction<Q[P]> };
17-
export interface RenderResult<ComponentType, WrapperType = ComponentType>
18-
extends RenderResultQueries,
19-
FireObject,
20-
UserEvents {
8+
export interface RenderResult<ComponentType, WrapperType = ComponentType> extends RenderResultQueries {
219
/**
2210
* @description
2311
* The containing DOM node of your rendered Angular Component.
@@ -70,26 +58,6 @@ export interface RenderResult<ComponentType, WrapperType = ComponentType>
7058
* Re-render the same component with different props.
7159
*/
7260
rerender: (componentProperties: Partial<ComponentType>) => void;
73-
/**
74-
* @deprecated
75-
* Usage of `waitForElementToBeRemoved` from render is deprecated, use this method directly from `@testing-library/angular`
76-
*
77-
* @description
78-
* Wait for the removal of element(s) from the DOM.
79-
*
80-
* For more info see https://testing-library.com/docs/dom-testing-library/api-async#waitforelementtoberemoved
81-
*/
82-
waitForElementToBeRemoved: typeof waitForElementToBeRemoved;
83-
/**
84-
* @deprecated
85-
* Usage of `waitFor` from render is deprecated, use this method directly from `@testing-library/angular`
86-
*
87-
* @description
88-
* When in need to wait for any period of time you can use waitFor, to wait for your expectations to pass.
89-
*
90-
* For more info see https://testing-library.com/docs/dom-testing-library/api-async#waitFor
91-
*/
92-
waitFor: typeof waitFor;
9361
}
9462

9563
export interface RenderComponentOptions<ComponentType, Q extends Queries = typeof queries> {

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /