Skip to content
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

feat(core): allow to throw on unknown properties in tests #45853

Closed

Conversation

cexbrayat
Copy link
Member

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Feature

What is the current behavior?

In a test, when using an unknown property in a template, we just get a console error.

This is similar to PR #45479 which introduced an errorOnUnknownElements option.

Issue Number: #36430

What is the new behavior?

Allows to provide a TestBed option to throw on unknown properties in templates:

getTestBed().initTestEnvironment(
  BrowserDynamicTestingModule,
  platformBrowserDynamicTesting(), {
    errorOnUnknownProperties: true
  }
);

Does this PR introduce a breaking change?

  • Yes
  • No

The default value of errorOnUnknownProperties is false, so this is not a breaking change.

Other information

@cexbrayat cexbrayat requested a review from AndrewKushnir May 3, 2022 16:59
@dylhunn dylhunn added the area: core Issues related to the framework runtime label May 3, 2022
@ngbot ngbot bot added this to the Backlog milestone May 3, 2022
@dylhunn dylhunn modified the milestones: Backlog, v14-candidates May 3, 2022
@dylhunn dylhunn added the target: minor This PR is targeted for the next minor release label May 3, 2022
@AndrewKushnir AndrewKushnir added the action: review The PR is still awaiting reviews from at least one requested reviewer label May 3, 2022
Copy link
Contributor

@AndrewKushnir AndrewKushnir left a comment

Choose a reason for hiding this comment

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

@cexbrayat thanks for the followup PR! I've added a couple minor comments, but overall the change looks good 👍

packages/core/test/acceptance/ng_module_spec.ts Outdated Show resolved Hide resolved
packages/core/test/acceptance/ng_module_spec.ts Outdated Show resolved Hide resolved
packages/core/testing/src/test_bed_common.ts Outdated Show resolved Hide resolved
@AndrewKushnir
Copy link
Contributor

Presubmit.

atscott
atscott previously approved these changes May 3, 2022
Copy link
Contributor

@atscott atscott left a comment

Choose a reason for hiding this comment

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

reviewed-for: public-api

AndrewKushnir
AndrewKushnir previously approved these changes May 3, 2022
Copy link
Contributor

@AndrewKushnir AndrewKushnir left a comment

Choose a reason for hiding this comment

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

Reviewed-for: public-api

@pullapprove pullapprove bot requested a review from jessicajaniuk May 3, 2022 19:47
@dylhunn dylhunn added action: presubmit The PR is in need of a google3 presubmit action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews action: review The PR is still awaiting reviews from at least one requested reviewer and removed action: review The PR is still awaiting reviews from at least one requested reviewer action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews action: presubmit The PR is in need of a google3 presubmit labels May 3, 2022
@dylhunn
Copy link
Contributor

dylhunn commented May 3, 2022

(sorry, was updating labels on the wrong PR!)

@cexbrayat @ me as soon as the comments are fixed, and we can sneak this one into 14! :)

Allows to provide a TestBed option to throw on unknown properties in templates:

```ts
getTestBed().initTestEnvironment(
  BrowserDynamicTestingModule,
  platformBrowserDynamicTesting(), {
    errorOnUnknownProperties: true
  }
);
```

The default value of `errorOnUnknownProperties` is `false`, so this is not a breaking change.
@cexbrayat cexbrayat dismissed stale reviews from AndrewKushnir and atscott via 959e5bc May 3, 2022 20:59
@cexbrayat cexbrayat force-pushed the feat/error-on-unknown-properties branch from cfc2db3 to 959e5bc Compare May 3, 2022 20:59
@cexbrayat
Copy link
Member Author

@dylhunn @AndrewKushnir Thanks for the review: PR updated with your feedback!

@AndrewKushnir AndrewKushnir removed the action: review The PR is still awaiting reviews from at least one requested reviewer label May 3, 2022
@AndrewKushnir AndrewKushnir added action: merge The PR is ready for merge by the caretaker merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note labels May 3, 2022
@AndrewKushnir
Copy link
Contributor

Merge-assistance: the necessary approvals were received, but reset due to an extra commit that addressed the feedback after the review. I've re-checked the code after the final update and things are looking good. The presubmit is "green", so the PR is now ready for merge.

@dylhunn
Copy link
Contributor

dylhunn commented May 3, 2022

This PR was merged into the repository by commit a667592.

@dylhunn dylhunn closed this in a667592 May 3, 2022
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Jun 3, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker area: core Issues related to the framework runtime merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note target: minor This PR is targeted for the next minor release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants