Skip to content

Updated testing-libary.ts #352

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ test('is possible to fill in a form and verify error messages (with the help of

const nameControl = screen.getByLabelText(/name/i);
const scoreControl = screen.getByRole('spinbutton', { name: /score/i });
const colorControl = screen.getByRole('combobox', { name: /color/i });
const colorControl = screen.getByPlaceholderText(/color/i);
const dateControl = screen.getByRole('textbox', { name: /Choose a date/i });

const errors = screen.getByRole('alert');
Expand Down Expand Up @@ -69,7 +69,7 @@ test('set and show pre-set form values', async () => {

const nameControl = screen.getByLabelText(/name/i);
const scoreControl = screen.getByRole('spinbutton', { name: /score/i });
const colorControl = screen.getByRole('combobox', { name: /color/i });
const colorControl = screen.getByPlaceholderText(/color/i);

expect(nameControl).toHaveValue('Max');
expect(scoreControl).toHaveValue(4);
Expand Down
42 changes: 21 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,34 +28,34 @@
"prepare": "git config core.hookspath .githooks"
},
"dependencies": {
"@angular/animations": "15.0.0",
"@angular/cdk": "15.0.0",
"@angular/common": "15.0.0",
"@angular/compiler": "15.0.0",
"@angular/core": "15.0.0",
"@angular/material": "15.0.0",
"@angular/platform-browser": "15.0.0",
"@angular/platform-browser-dynamic": "15.0.0",
"@angular/router": "15.0.0",
"@ngrx/store": "15.0.0",
"@angular/animations": "15.1.0",
"@angular/cdk": "15.1.0",
"@angular/common": "15.1.0",
"@angular/compiler": "15.1.0",
"@angular/core": "15.1.0",
"@angular/material": "15.1.0",
"@angular/platform-browser": "15.1.0",
"@angular/platform-browser-dynamic": "15.1.0",
"@angular/router": "15.1.0",
"@ngrx/store": "15.1.0",
"@nrwl/angular": "15.4.5",
"@nrwl/nx-cloud": "15.0.2",
"@testing-library/dom": "^8.11.1",
"@testing-library/dom": "^8.19.1",
"rxjs": "7.5.6",
"tslib": "~2.3.1",
"zone.js": "~0.11.4"
},
"devDependencies": {
"@angular-devkit/build-angular": "15.0.0",
"@angular-eslint/builder": "15.0.0",
"@angular-eslint/eslint-plugin": "15.0.0",
"@angular-eslint/eslint-plugin-template": "15.0.0",
"@angular-eslint/schematics": "15.0.0",
"@angular-eslint/template-parser": "15.0.0",
"@angular-devkit/build-angular": "15.1.0",
"@angular-eslint/builder": "15.1.0",
"@angular-eslint/eslint-plugin": "15.1.0",
"@angular-eslint/eslint-plugin-template": "15.1.0",
"@angular-eslint/schematics": "15.1.0",
"@angular-eslint/template-parser": "15.1.0",
"@angular/cli": "~15.0.0",
"@angular/compiler-cli": "15.0.0",
"@angular/forms": "15.0.0",
"@angular/language-service": "15.0.0",
"@angular/compiler-cli": "15.1.0",
"@angular/forms": "15.1.0",
"@angular/language-service": "15.1.0",
"@nrwl/cli": "15.4.5",
"@nrwl/eslint-plugin-nx": "15.4.5",
"@nrwl/jest": "15.4.5",
Expand All @@ -66,7 +66,7 @@
"@swc-node/register": "^1.4.2",
"@swc/core": "^1.2.173",
"@testing-library/jasmine-dom": "^1.2.0",
"@testing-library/jest-dom": "^5.15.1",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/user-event": "^13.5.0",
"@types/jasmine": "4.0.3",
"@types/jest": "28.1.8",
Expand Down
8 changes: 4 additions & 4 deletions projects/testing-library/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@
"migrations": "./schematics/migrations/migration.json"
},
"peerDependencies": {
"@angular/common": ">= 15.0.0",
"@angular/platform-browser": ">= 15.0.0",
"@angular/router": ">= 15.0.0",
"@angular/core": ">= 15.0.0"
"@angular/common": ">= 15.1.0",
"@angular/platform-browser": ">= 15.1.0",
"@angular/router": ">= 15.1.0",
"@angular/core": ">= 15.1.0"
},
"dependencies": {
"@testing-library/dom": "^8.0.0",
Expand Down
8 changes: 4 additions & 4 deletions projects/testing-library/src/lib/testing-library.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
OnChanges,
SimpleChanges,
ApplicationInitStatus,
ɵisStandalone,
isStandalone,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know if this also works with Angular v15.0 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it does not work with Angular v15.0 since they introduced this breaking change first at v15.1.

} from '@angular/core';
import { ComponentFixture, TestBed, tick } from '@angular/core/testing';
import { BrowserAnimationsModule, NoopAnimationsModule } from '@angular/platform-browser/animations';
Expand Down Expand Up @@ -321,7 +321,7 @@ function setComponentInputs<SutType>(

function overrideComponentImports<SutType>(sut: Type<SutType> | string, imports: (Type<any> | any[])[] | undefined) {
if (imports) {
if (typeof sut === 'function' && ɵisStandalone(sut)) {
if (typeof sut === 'function' && isStandalone(sut)) {
TestBed.overrideComponent(sut, { set: { imports } });
} else {
throw new Error(
Expand Down Expand Up @@ -369,7 +369,7 @@ function addAutoDeclarations<SutType>(
return [...declarations, wrapper];
}

const components = () => (excludeComponentDeclaration || ɵisStandalone(sut) ? [] : [sut]);
const components = () => (excludeComponentDeclaration || isStandalone(sut) ? [] : [sut]);
return [...declarations, ...components()];
}

Expand All @@ -384,7 +384,7 @@ function addAutoImports<SutType>(
};

const routing = () => (routes ? [RouterTestingModule.withRoutes(routes)] : []);
const components = () => (typeof sut !== 'string' && ɵisStandalone(sut) ? [sut] : []);
const components = () => (typeof sut !== 'string' && isStandalone(sut) ? [sut] : []);
return [...imports, ...components(), ...animations(), ...routing()];
}

Expand Down