question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Feature]: Allow configuring `errorOnUnknownElements` and `errorOnUnknownProperties` for setup test env

See original GitHub issue

🚀 Feature Proposal

Allow configuring errorOnUnknownElements and errorOnUnknownProperties is test environment option

see: https://angular.io/api/core/testing/TestEnvironmentOptions

Motivation

This new properties has been introduce in angular V14. This is usefull to throw errors on unknown elements or properties found in a template

Example

like destroyAfterEach option, we could add errorOnUnknownElements and errorOnUnknownProperties

globalThis.ngJest = {
  errorOnUnknownElements: true,
  errorOnUnknownProperties: true,
};

As TestEnvironmentOptions may introduce more properties in the future, we could add testEnvironmentOptions property in config:

globalThis.ngJest = {
  testEnvironmentOptions: {
    errorOnUnknownElements: true,
    errorOnUnknownProperties: true,
    teardown: { destroyAfterEach: false },
  },

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
Yohandahcommented, Aug 23, 2022

@cedricduffournet yeah that’s because I’ve added the options directly inside jest.config.js, I pushed the change. I will try to see with @angular-builders/jest maintainer. He’s saying I should pass the setup file as a CLI arg but I can’t see why since the setup file is already referenced inside jest.config.js https://github.com/just-jeb/angular-builders/issues/1245#issuecomment-1223769770

Thanks anyway for trying to help !

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unit test should fail if an element is not known #36430 - GitHub
You can now enable errorOnUnknownElements and/or errorOnUnknownProperties when setting up the TestBed globally or in a specific test to ...
Read more >
What's new in Angular CLI 15.0? - Ninja Squad
Let's see what we've got in this release. ... The fileReplacements configuration has been removed from the angular.json file.
Read more >
Add Angular 15 Missing Files - JavaScript in Plain English
// First, initialize the Angular testing environment. getTestBed().initTestEnvironment( BrowserDynamicTestingModule,
Read more >
Test environment | jest-preset-angular - GitHub Pages
Configure test environment ​. When creating Angular test environment with TestBed , it is possible to specify the testEnvironmentOptions via globalThis in the ......
Read more >
Configure unit tests by using a .runsettings file - Microsoft Learn
Learn how to use the .runsettings file in Visual Studio to configure unit tests that are run from the command line, from the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found