From 1c21e470c76d69d08e5096b46b952dbce330f7ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Exbrayat?= Date: Thu, 15 Sep 2022 11:03:07 +0200 Subject: [PATCH] feat(@schematics/angular): enable error on unknown properties and elements in tests These new options have been introduced in Angular v14. The commit enables the option in a new project, as we did when we introduced the `destroyAfterOption`, with the same long term goal to have these options enabled by default. --- .../build_angular/test/hello-world-app/src/test.ts | 8 ++++---- .../test/hello-world-lib/projects/lib/src/test.ts | 8 ++++---- .../angular/application/files/src/test.ts.template | 8 ++++---- .../schematics/angular/library/files/src/test.ts.template | 8 ++++---- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/packages/angular_devkit/build_angular/test/hello-world-app/src/test.ts b/packages/angular_devkit/build_angular/test/hello-world-app/src/test.ts index d2dd986c8a58..149a98c3c157 100644 --- a/packages/angular_devkit/build_angular/test/hello-world-app/src/test.ts +++ b/packages/angular_devkit/build_angular/test/hello-world-app/src/test.ts @@ -23,10 +23,10 @@ declare const require: { }; // First, initialize the Angular testing environment. -getTestBed().initTestEnvironment( - BrowserDynamicTestingModule, - platformBrowserDynamicTesting(), -); +getTestBed().initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting(), { + errorOnUnknownElements: true, + errorOnUnknownProperties: true +}); // Then we find all the tests. const context = require.context('./', true, /\.spec\.ts$/); // And load the modules. diff --git a/packages/angular_devkit/build_angular/test/hello-world-lib/projects/lib/src/test.ts b/packages/angular_devkit/build_angular/test/hello-world-lib/projects/lib/src/test.ts index 2e06d42dae8a..a24258af75ba 100644 --- a/packages/angular_devkit/build_angular/test/hello-world-lib/projects/lib/src/test.ts +++ b/packages/angular_devkit/build_angular/test/hello-world-lib/projects/lib/src/test.ts @@ -24,10 +24,10 @@ declare const require: { }; // First, initialize the Angular testing environment. -getTestBed().initTestEnvironment( - BrowserDynamicTestingModule, - platformBrowserDynamicTesting(), -); +getTestBed().initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting(), { + errorOnUnknownElements: true, + errorOnUnknownProperties: true +}); // Then we find all the tests. const context = require.context('./', true, /\.spec\.ts$/); // And load the modules. diff --git a/packages/schematics/angular/application/files/src/test.ts.template b/packages/schematics/angular/application/files/src/test.ts.template index c04c876075f9..cac5aa3ea352 100644 --- a/packages/schematics/angular/application/files/src/test.ts.template +++ b/packages/schematics/angular/application/files/src/test.ts.template @@ -15,10 +15,10 @@ declare const require: { }; // First, initialize the Angular testing environment. -getTestBed().initTestEnvironment( - BrowserDynamicTestingModule, - platformBrowserDynamicTesting(), -); +getTestBed().initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting(), { + errorOnUnknownElements: true, + errorOnUnknownProperties: true +}); // Then we find all the tests. const context = require.context('./', true, /\.spec\.ts$/); diff --git a/packages/schematics/angular/library/files/src/test.ts.template b/packages/schematics/angular/library/files/src/test.ts.template index 5775317abc9f..29e4db3829fe 100644 --- a/packages/schematics/angular/library/files/src/test.ts.template +++ b/packages/schematics/angular/library/files/src/test.ts.template @@ -16,10 +16,10 @@ declare const require: { }; // First, initialize the Angular testing environment. -getTestBed().initTestEnvironment( - BrowserDynamicTestingModule, - platformBrowserDynamicTesting(), -); +getTestBed().initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting(), { + errorOnUnknownElements: true, + errorOnUnknownProperties: true +}); // Then we find all the tests. const context = require.context('./', true, /\.spec\.ts$/);