diff --git a/apps/example-app-karma/src/test.ts b/apps/example-app-karma/src/test.ts index 0a45adb5..827caf48 100644 --- a/apps/example-app-karma/src/test.ts +++ b/apps/example-app-karma/src/test.ts @@ -2,11 +2,7 @@ import 'zone.js/dist/zone-testing'; import { getTestBed } from '@angular/core/testing'; import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing'; -import JasmineDOM from '@testing-library/jasmine-dom/dist'; - -beforeAll(() => { - (jasmine.getEnv() as any).addMatchers(JasmineDOM); -}); +import '@testing-library/jasmine-dom'; declare const require: any; diff --git a/apps/example-app/src/app/examples/01-nested-component.ts b/apps/example-app/src/app/examples/01-nested-component.ts index 5b0faeb2..51087b44 100644 --- a/apps/example-app/src/app/examples/01-nested-component.ts +++ b/apps/example-app/src/app/examples/01-nested-component.ts @@ -5,7 +5,7 @@ import { Component, Input, Output, EventEmitter } from '@angular/core'; template: ' ', }) export class NestedButtonComponent { - @Input() name: string; + @Input() name = ''; @Output() raise = new EventEmitter(); } @@ -14,7 +14,7 @@ export class NestedButtonComponent { template: ' {{ value }} ', }) export class NestedValueComponent { - @Input() value: number; + @Input() value?: number; } @Component({ diff --git a/apps/example-app/src/app/examples/03-forms.ts b/apps/example-app/src/app/examples/03-forms.ts index bc035a14..f68766e4 100644 --- a/apps/example-app/src/app/examples/03-forms.ts +++ b/apps/example-app/src/app/examples/03-forms.ts @@ -1,5 +1,5 @@ import { Component } from '@angular/core'; -import { FormBuilder, Validators, ValidationErrors } from '@angular/forms'; +import { FormBuilder, Validators } from '@angular/forms'; @Component({ selector: 'app-fixture', @@ -46,8 +46,8 @@ export class FormsComponent { get formErrors() { return Object.keys(this.form.controls) .map((formKey) => { - const controlErrors: ValidationErrors = this.form.get(formKey).errors; - if (controlErrors != null) { + const controlErrors = this.form.get(formKey)?.errors; + if (controlErrors) { return Object.keys(controlErrors).map((keyError) => { const error = controlErrors[keyError]; switch (keyError) { diff --git a/apps/example-app/src/app/examples/04-forms-with-material.spec.ts b/apps/example-app/src/app/examples/04-forms-with-material.spec.ts index c215d9c4..ee4209b9 100644 --- a/apps/example-app/src/app/examples/04-forms-with-material.spec.ts +++ b/apps/example-app/src/app/examples/04-forms-with-material.spec.ts @@ -44,6 +44,5 @@ test('is possible to fill in a form and verify error messages (with the help of score: 7, }); - // not added to the form? - expect((fixture.componentInstance as MaterialFormsComponent).form.get('color').value).toBe('G'); + expect((fixture.componentInstance as MaterialFormsComponent).form?.get('color')?.value).toBe('G'); }); diff --git a/apps/example-app/src/app/examples/04-forms-with-material.ts b/apps/example-app/src/app/examples/04-forms-with-material.ts index 2718e389..a672380c 100644 --- a/apps/example-app/src/app/examples/04-forms-with-material.ts +++ b/apps/example-app/src/app/examples/04-forms-with-material.ts @@ -1,5 +1,5 @@ import { Component } from '@angular/core'; -import { FormBuilder, Validators, ValidationErrors } from '@angular/forms'; +import { FormBuilder, Validators } from '@angular/forms'; @Component({ selector: 'app-fixture', @@ -68,8 +68,8 @@ export class MaterialFormsComponent { get formErrors() { return Object.keys(this.form.controls) .map((formKey) => { - const controlErrors: ValidationErrors = this.form.get(formKey).errors; - if (controlErrors != null) { + const controlErrors = this.form.get(formKey)?.errors; + if (controlErrors) { return Object.keys(controlErrors).map((keyError) => { const error = controlErrors[keyError]; switch (keyError) { diff --git a/apps/example-app/src/app/examples/06-with-ngrx-store.ts b/apps/example-app/src/app/examples/06-with-ngrx-store.ts index f260b978..470f52d9 100644 --- a/apps/example-app/src/app/examples/06-with-ngrx-store.ts +++ b/apps/example-app/src/app/examples/06-with-ngrx-store.ts @@ -3,16 +3,12 @@ import { createSelector, Store, createAction, createReducer, on, select } from ' const increment = createAction('increment'); const decrement = createAction('decrement'); -const counterReducer = createReducer( +export const reducer = createReducer( 0, on(increment, (state) => state + 1), on(decrement, (state) => state - 1), ); -export function reducer(state, action) { - return counterReducer(state, action); -} - const selectValue = createSelector( (state: any) => state.value, (value) => value * 10, diff --git a/apps/example-app/src/app/examples/08-directive.spec.ts b/apps/example-app/src/app/examples/08-directive.spec.ts index 5df9413a..ea3332b4 100644 --- a/apps/example-app/src/app/examples/08-directive.spec.ts +++ b/apps/example-app/src/app/examples/08-directive.spec.ts @@ -36,11 +36,11 @@ test('it is possible to test directives with props', async () => { expect(screen.queryByText(visible)).not.toBeInTheDocument(); expect(screen.queryByText(hidden)).toBeInTheDocument(); - fireEvent.mouseOver(screen.queryByText(hidden)); + fireEvent.mouseOver(screen.getByText(hidden)); expect(screen.queryByText(hidden)).not.toBeInTheDocument(); expect(screen.queryByText(visible)).toBeInTheDocument(); - fireEvent.mouseLeave(screen.queryByText(visible)); + fireEvent.mouseLeave(screen.getByText(visible)); expect(screen.queryByText(hidden)).toBeInTheDocument(); expect(screen.queryByText(visible)).not.toBeInTheDocument(); }); @@ -56,11 +56,11 @@ test('it is possible to test directives with props in template', async () => { expect(screen.queryByText(visible)).not.toBeInTheDocument(); expect(screen.queryByText(hidden)).toBeInTheDocument(); - fireEvent.mouseOver(screen.queryByText(hidden)); + fireEvent.mouseOver(screen.getByText(hidden)); expect(screen.queryByText(hidden)).not.toBeInTheDocument(); expect(screen.queryByText(visible)).toBeInTheDocument(); - fireEvent.mouseLeave(screen.queryByText(visible)); + fireEvent.mouseLeave(screen.getByText(visible)); expect(screen.queryByText(hidden)).toBeInTheDocument(); expect(screen.queryByText(visible)).not.toBeInTheDocument(); }); diff --git a/apps/example-app/src/app/examples/12-service-component.ts b/apps/example-app/src/app/examples/12-service-component.ts index af35f10a..d272e270 100644 --- a/apps/example-app/src/app/examples/12-service-component.ts +++ b/apps/example-app/src/app/examples/12-service-component.ts @@ -2,8 +2,8 @@ import { Component, Injectable } from '@angular/core'; import { Observable, of } from 'rxjs'; export class Customer { - id: string; - name: string; + id!: string; + name!: string; } @Injectable({ diff --git a/apps/example-app/src/app/examples/15-dialog.component.spec.ts b/apps/example-app/src/app/examples/15-dialog.component.spec.ts index f0fbd465..8a0ccd88 100644 --- a/apps/example-app/src/app/examples/15-dialog.component.spec.ts +++ b/apps/example-app/src/app/examples/15-dialog.component.spec.ts @@ -37,8 +37,8 @@ test('closes the dialog via the backdrop', async () => { // using fireEvent because of: // unable to click element as it has or inherits pointer-events set to "none" - // eslint-disable-next-line testing-library/no-node-access - fireEvent.click(document.querySelector('.cdk-overlay-backdrop')); + // eslint-disable-next-line testing-library/no-node-access, @typescript-eslint/no-non-null-assertion + fireEvent.click(document.querySelector('.cdk-overlay-backdrop')!); await waitForElementToBeRemoved(() => screen.getByRole('dialog')); diff --git a/apps/example-app/src/app/examples/16-input-getter-setter.ts b/apps/example-app/src/app/examples/16-input-getter-setter.ts index 11f8c949..22d9641a 100644 --- a/apps/example-app/src/app/examples/16-input-getter-setter.ts +++ b/apps/example-app/src/app/examples/16-input-getter-setter.ts @@ -18,6 +18,6 @@ export class InputGetterSetter { return 'I am value from getter ' + this.originalValue; } - private originalValue: string; - derivedValue: string; + private originalValue?: string; + derivedValue?: string; } diff --git a/apps/example-app/src/app/issues/issue-254.spec.ts b/apps/example-app/src/app/issues/issue-254.spec.ts index 01960b4f..74e90fbb 100644 --- a/apps/example-app/src/app/issues/issue-254.spec.ts +++ b/apps/example-app/src/app/issues/issue-254.spec.ts @@ -1,12 +1,11 @@ -/* eslint-disable @typescript-eslint/naming-convention */ import { Component, Inject, OnInit } from '@angular/core'; import { render, screen } from '@testing-library/angular'; import { createMock } from '@testing-library/angular/jest-utils'; interface Division { - JobType: string; - JobBullets: string[]; - Description: string; + jobType?: string; + jobBullets?: string[]; + description?: string; } @Inject({ @@ -21,25 +20,25 @@ class JobsService { @Component({ selector: 'app-home-career-oportunities', template: ` `, }) class CareerOportunitiesComponent implements OnInit { - dedicated = {} as Division; - intermodal = {} as Division; - noCdl = {} as Division; - otr = {} as Division; + dedicated?: Division; + intermodal?: Division; + noCdl?: Division; + otr?: Division; constructor(private jobsService: JobsService) {} ngOnInit(): void { this.jobsService.divisions().then((apiDivisions) => { - this.dedicated = apiDivisions.find((c) => c.JobType === 'DEDICATED'); - this.intermodal = apiDivisions.find((c) => c.JobType === 'INTERMODAL'); - this.noCdl = apiDivisions.find((c) => c.JobType === 'NO_CDL'); - this.otr = apiDivisions.find((c) => c.JobType === 'OVER_THE_ROAD'); + this.dedicated = apiDivisions.find((c) => c.jobType === 'DEDICATED'); + this.intermodal = apiDivisions.find((c) => c.jobType === 'INTERMODAL'); + this.noCdl = apiDivisions.find((c) => c.jobType === 'NO_CDL'); + this.otr = apiDivisions.find((c) => c.jobType === 'OVER_THE_ROAD'); }); } } @@ -47,20 +46,20 @@ class CareerOportunitiesComponent implements OnInit { test('Render Component', async () => { const divisions2: Division[] = [ { - JobType: 'INTERMODAL', - JobBullets: ['Local Routes', 'Flexible Schedules', 'Competitive Pay'], - Description: '', + jobType: 'INTERMODAL', + jobBullets: ['Local Routes', 'Flexible Schedules', 'Competitive Pay'], + description: '', }, - { JobType: 'NO_CDL', JobBullets: ['We Train', 'We Hire', 'We Pay'], Description: '' }, + { jobType: 'NO_CDL', jobBullets: ['We Train', 'We Hire', 'We Pay'], description: '' }, { - JobType: 'OVER_THE_ROAD', - JobBullets: ['Great Miles', 'Competitive Pay', 'Explore the Country'], - Description: '', + jobType: 'OVER_THE_ROAD', + jobBullets: ['Great Miles', 'Competitive Pay', 'Explore the Country'], + description: '', }, { - JobType: 'DEDICATED', - JobBullets: ['Regular Routes', 'Consistent Miles', 'Great Pay'], - Description: '', + jobType: 'DEDICATED', + jobBullets: ['Regular Routes', 'Consistent Miles', 'Great Pay'], + description: '', }, ]; const jobService = createMock(JobsService); diff --git a/projects/testing-library/.eslintrc.json b/projects/testing-library/.eslintrc.json index 4089aa79..918e7859 100644 --- a/projects/testing-library/.eslintrc.json +++ b/projects/testing-library/.eslintrc.json @@ -2,6 +2,12 @@ "extends": "../../.eslintrc.json", "ignorePatterns": ["!**/*"], "overrides": [ + { + "files": ["*.ts"], + "rules": { + "@typescript-eslint/ban-ts-comment": "off" + } + }, { "files": ["*.ts"], "extends": ["plugin:@nrwl/nx/angular", "plugin:@angular-eslint/template/process-inline-templates"], @@ -9,6 +15,7 @@ "project": ["projects/testing-library/tsconfig.*?.json"] }, "rules": { + "@typescript-eslint/ban-ts-comment": "off", "@angular-eslint/directive-selector": [ "error", { diff --git a/projects/testing-library/src/lib/models.ts b/projects/testing-library/src/lib/models.ts index 7f5a02a7..9320fb6a 100644 --- a/projects/testing-library/src/lib/models.ts +++ b/projects/testing-library/src/lib/models.ts @@ -268,8 +268,8 @@ export interface RenderTemplateOptions` + * const component = await render(`
`, { + * declarations: [SpoilerDirective] * wrapper: CustomWrapperComponent * }) */ diff --git a/projects/testing-library/src/lib/testing-library.ts b/projects/testing-library/src/lib/testing-library.ts index 1a517aa2..1197cf8e 100644 --- a/projects/testing-library/src/lib/testing-library.ts +++ b/projects/testing-library/src/lib/testing-library.ts @@ -53,8 +53,7 @@ export async function render( providers = [], schemas = [], queries, - template = undefined, - wrapper = WrapperComponent, + wrapper = WrapperComponent as Type, componentProperties = {}, componentProviders = [], excludeComponentDeclaration = false, @@ -89,13 +88,13 @@ export async function render( await TestBed.compileComponents(); componentProviders - .reduce((acc, provider) => acc.concat(provider), []) - .forEach((p) => { + .reduce((acc, provider) => acc.concat(provider), [] as any[]) + .forEach((p: any) => { const { provide, ...provider } = p; TestBed.overrideProvider(provide, provider); }); - const componentContainer = createComponentFixture(sut, { wrapper }); + const componentContainer = createComponentFixture(sut, wrapper); let fixture: ComponentFixture; let detectChanges: () => void; @@ -120,7 +119,7 @@ export async function render( let router = routes ? inject(Router) : null; const zone = inject(NgZone); - const navigate = async (elementOrPath: Element | string, basePath = '') => { + const navigate = async (elementOrPath: Element | string, basePath = ''): Promise => { if (!router) { router = inject(Router); } @@ -139,16 +138,18 @@ export async function render( qp[key] = [currentValue, value]; } return qp; - }, {}) + }, {} as Record) : undefined; - const navigateOptions: NavigationExtras = queryParams + const navigateOptions: NavigationExtras | undefined = queryParams ? { queryParams, } : undefined; - const doNavigate = () => (navigateOptions ? router.navigate([path], navigateOptions) : router.navigate([path])); + const doNavigate = () => { + return navigateOptions ? router?.navigate([path], navigateOptions) : router?.navigate([path]); + }; let result; @@ -159,21 +160,25 @@ export async function render( } detectChanges(); - return result; + return result ?? false; }; return { + // @ts-ignore: fixture assigned fixture, detectChanges: () => detectChanges(), navigate, rerender, change, + // @ts-ignore: fixture assigned debugElement: typeof sut === 'string' ? fixture.debugElement : fixture.debugElement.query(By.directive(sut)), + // @ts-ignore: fixture assigned container: fixture.nativeElement, debug: (element = fixture.nativeElement, maxLength, options) => Array.isArray(element) ? element.forEach((e) => console.log(dtlPrettyDOM(e, maxLength, options))) : console.log(dtlPrettyDOM(element, maxLength, options)), + // @ts-ignore: fixture assigned ...replaceFindWithFindAndDetectChanges(dtlGetQueriesForElement(fixture.nativeElement, queries)), }; @@ -220,9 +225,9 @@ async function createComponent(component: Type): Promise( +function createComponentFixture( sut: Type | string, - { wrapper }: Pick, 'wrapper'>, + wrapper: Type, ): Type { if (typeof sut === 'string') { TestBed.overrideTemplate(wrapper, sut); @@ -236,13 +241,10 @@ function setComponentProperties( { componentProperties = {} }: Pick, 'componentProperties'>, ) { for (const key of Object.keys(componentProperties)) { - const descriptor: PropertyDescriptor = Object.getOwnPropertyDescriptor( - fixture.componentInstance.constructor.prototype, - key, - ); + const descriptor = Object.getOwnPropertyDescriptor((fixture.componentInstance as any).constructor.prototype, key); let _value = componentProperties[key]; const defaultGetter = () => _value; - const extendedSetter = (value) => { + const extendedSetter = (value: any) => { _value = value; descriptor?.set?.call(fixture.componentInstance, _value); fixture.detectChanges(); @@ -268,21 +270,24 @@ function hasOnChangesHook(componentInstance: SutType): componentInstanc ); } -function getChangesObj(oldProps: Partial | null, newProps: Partial) { +function getChangesObj>( + oldProps: Partial | null, + newProps: Partial, +) { const isFirstChange = oldProps === null; return Object.keys(newProps).reduce( (changes, key) => ({ ...changes, [key]: new SimpleChange(isFirstChange ? null : oldProps[key], newProps[key], isFirstChange), }), - {}, + {} as SutType, ); } function addAutoDeclarations( sut: Type | string, { - declarations, + declarations = [], excludeComponentDeclaration, wrapper, }: Pick, 'declarations' | 'excludeComponentDeclaration' | 'wrapper'>, @@ -295,7 +300,7 @@ function addAutoDeclarations( return [...declarations, ...components()]; } -function addAutoImports({ imports, routes }: Pick, 'imports' | 'routes'>) { +function addAutoImports({ imports = [], routes }: Pick, 'imports' | 'routes'>) { const animations = () => { const animationIsDefined = imports.indexOf(NoopAnimationsModule) > -1 || imports.indexOf(BrowserAnimationsModule) > -1; @@ -341,19 +346,19 @@ async function waitForElementToBeRemovedWrapper( callback: (() => T) | T, options?: dtlWaitForOptions, ): Promise { - let cb; + let cb: () => T; if (typeof callback !== 'function') { const elements = (Array.isArray(callback) ? callback : [callback]) as Element[]; const getRemainingElements = elements.map((element) => { - let parent = element.parentElement; + let parent = element.parentElement as Element; while (parent.parentElement) { parent = parent.parentElement; } return () => (parent.contains(element) ? element : null); }); - cb = () => getRemainingElements.map((c) => c()).filter(Boolean); + cb = () => getRemainingElements.map((c) => c()).find(Boolean) as unknown as T; } else { - cb = callback; + cb = callback as () => T; } return await dtlWaitForElementToBeRemoved(() => { @@ -367,7 +372,7 @@ function cleanup() { mountedFixtures.forEach(cleanupAtFixture); } -function cleanupAtFixture(fixture) { +function cleanupAtFixture(fixture: ComponentFixture) { fixture.destroy(); if (!fixture.nativeElement.getAttribute('ng-version') && fixture.nativeElement.parentNode === document.body) { @@ -394,25 +399,21 @@ class WrapperComponent {} /** * Wrap findBy queries to poke the Angular change detection cycle */ -function replaceFindWithFindAndDetectChanges(originalQueriesForContainer: T): T { +function replaceFindWithFindAndDetectChanges>(originalQueriesForContainer: T): T { return Object.keys(originalQueriesForContainer).reduce((newQueries, key) => { const getByQuery = originalQueriesForContainer[key.replace('find', 'get')]; if (key.startsWith('find') && getByQuery) { - newQueries[key] = async (text, options, waitOptions) => { + newQueries[key] = async (...queryOptions: any[]) => { + const waitOptions = queryOptions.length === 3 ? queryOptions.pop() : undefined; // original implementation at https://github.com/testing-library/dom-testing-library/blob/main/src/query-helpers.js - const result = await waitForWrapper( - detectChangesForMountedFixtures, - () => getByQuery(text, options), - waitOptions, - ); - return result; + return await waitForWrapper(detectChangesForMountedFixtures, () => getByQuery(...queryOptions), waitOptions); }; } else { newQueries[key] = originalQueriesForContainer[key]; } return newQueries; - }, {} as T); + }, {} as Record) as T; } /** @@ -422,7 +423,7 @@ function detectChangesForMountedFixtures() { mountedFixtures.forEach((fixture) => { try { fixture.detectChanges(); - } catch (err) { + } catch (err: any) { if (!err.message.startsWith('ViewDestroyedError')) { throw err; } diff --git a/projects/testing-library/tests/auto-cleanup.spec.ts b/projects/testing-library/tests/auto-cleanup.spec.ts index c69eda62..1e37f242 100644 --- a/projects/testing-library/tests/auto-cleanup.spec.ts +++ b/projects/testing-library/tests/auto-cleanup.spec.ts @@ -6,7 +6,7 @@ import { render } from '../src/public_api'; template: `Hello {{ name }}!`, }) class FixtureComponent { - @Input() name: string; + @Input() name = ''; } describe('Angular auto clean up - previous components only get cleanup up on init (based on root-id)', () => { diff --git a/projects/testing-library/tests/change.spec.ts b/projects/testing-library/tests/change.spec.ts index 85cc3667..1ba67513 100644 --- a/projects/testing-library/tests/change.spec.ts +++ b/projects/testing-library/tests/change.spec.ts @@ -7,7 +7,7 @@ import { render, screen } from '../src/public_api'; }) class FixtureComponent { @Input() firstName = 'Sarah'; - @Input() lastName; + @Input() lastName?: string; } test('changes the component with updated props', async () => { @@ -44,7 +44,7 @@ test('changes the component with updated props while keeping other props untouch }) class FixtureWithNgOnChangesComponent implements OnChanges { @Input() name = 'Sarah'; - @Input() nameChanged: (name: string, isFirstChange: boolean) => void; + @Input() nameChanged?: (name: string, isFirstChange: boolean) => void; ngOnChanges(changes: SimpleChanges) { if (changes.name && this.nameChanged) { @@ -72,7 +72,7 @@ test('will call ngOnChanges on change', async () => { template: `
Number
`, }) class FixtureWithOnPushComponent { - @Input() activeField: string; + @Input() activeField = ''; } test('update properties on change', async () => { diff --git a/projects/testing-library/tests/config.spec.ts b/projects/testing-library/tests/config.spec.ts index ccd004f5..bb8c61fc 100644 --- a/projects/testing-library/tests/config.spec.ts +++ b/projects/testing-library/tests/config.spec.ts @@ -1,6 +1,6 @@ import { Component } from '@angular/core'; import { TestBed } from '@angular/core/testing'; -import { render, configure } from '../src/public_api'; +import { render, configure, Config } from '../src/public_api'; import { ReactiveFormsModule, FormBuilder } from '@angular/forms'; @Component({ @@ -22,12 +22,12 @@ class FormsComponent { constructor(private formBuilder: FormBuilder) {} } -let originalConfig; +let originalConfig: Config; beforeEach(() => { // Grab the existing configuration so we can restore // it at the end of the test configure((existingConfig) => { - originalConfig = existingConfig; + originalConfig = existingConfig as Config; // Don't change the existing config return {}; }); diff --git a/projects/testing-library/tests/integration.spec.ts b/projects/testing-library/tests/integration.spec.ts index afd56698..112177e1 100644 --- a/projects/testing-library/tests/integration.spec.ts +++ b/projects/testing-library/tests/integration.spec.ts @@ -36,7 +36,9 @@ class EntitiesComponent { query = new BehaviorSubject(''); readonly entities = this.query.pipe( debounceTime(DEBOUNCE_TIME), - switchMap((q) => this.entitiesService.fetchAll().pipe(map((ent) => ent.filter((e) => e.name.includes(q))))), + switchMap((q) => + this.entitiesService.fetchAll().pipe(map((ent: any) => ent.filter((e: any) => e.name.includes(q)))), + ), startWith(entities), ); @@ -65,7 +67,7 @@ class EntitiesComponent { `, }) class TableComponent { - @Input() entities: any[]; + @Input() entities: any[] = []; @Output() edit = new EventEmitter(); } diff --git a/projects/testing-library/tests/issues/issue-188.spec.ts b/projects/testing-library/tests/issues/issue-188.spec.ts index 8077358a..b150dacc 100644 --- a/projects/testing-library/tests/issues/issue-188.spec.ts +++ b/projects/testing-library/tests/issues/issue-188.spec.ts @@ -6,9 +6,9 @@ import { render, screen } from '../../src/public_api'; template: `

Hello {{ formattedName }}

`, }) class BugOnChangeComponent implements OnChanges { - @Input() name: string; + @Input() name?: string; - formattedName: string; + formattedName?: string; ngOnChanges(changes: SimpleChanges) { if (changes.name) { diff --git a/projects/testing-library/tests/rerender.spec.ts b/projects/testing-library/tests/rerender.spec.ts index 443560a2..0edf69ea 100644 --- a/projects/testing-library/tests/rerender.spec.ts +++ b/projects/testing-library/tests/rerender.spec.ts @@ -7,7 +7,7 @@ import { render, screen } from '../src/public_api'; }) class FixtureComponent { @Input() firstName = 'Sarah'; - @Input() lastName; + @Input() lastName?: string; } test('rerenders the component with updated props', async () => { diff --git a/tsconfig.base.json b/tsconfig.base.json index 0ad01d03..59f62014 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -13,9 +13,12 @@ "sourceMap": true, "target": "es2015", "typeRoots": ["node_modules/@types"], - "forceConsistentCasingInFileNames": true, - "noImplicitReturns": true, + "strict": true, "noFallthroughCasesInSwitch": true, + "noImplicitReturns": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "forceConsistentCasingInFileNames": true, "paths": { "@testing-library/angular": ["projects/testing-library"], "@testing-library/angular/jest-utils": ["projects/jest-utils"]