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(ct): add mount support for template strings #6

Conversation

chronospatian
Copy link

@chronospatian chronospatian commented May 15, 2024

This PR adds support for mounting Angular components via a template string. This enables a number of additional test cases:

  1. Testing content projection via ng-content
  2. Testing directives
  3. Testing pipes
  4. Testing component boundaries

Mount has been extended with the following additional options:

imports - If a string template is passed to mount, imports are passed to WrapperComponent imports. If a component is passed to mount, imports are passed to TestBed.configureModule. It is done this way to prevent users from adding new declarables to the component's scope.


The intention behind adding the following options is to enable testing all of the component's boundaries. They are not needed for mounting template strings.

environmentProviders - Passed to TestBed.configureModule for top level providers that should exist outside of the component injector, such as provideStore from ngrx.

providers/viewProviders - Passed to TestBed.overrideComponent intended for stubbing component level providers.


This PR also contains a number of fixes for the mount function so that it reuses the root element given by Playwright and properly maps aliased component outputs.

@chronospatian
Copy link
Author

chronospatian commented May 15, 2024

@chronospatian
Copy link
Author

For template string compilation to work, the code must be compiled in JIT mode.

@sand4rt
Copy link
Owner

sand4rt commented May 17, 2024

Hi @chronospatian, thanks for your effort. However, we previously decided to hold off on supporting template/imports/providers until the library is merged. Otherwise, we risk continually adding features and delaying the merge indefinitely. So, I'm closing this for now.

@sand4rt sand4rt closed this May 17, 2024
@chronospatian
Copy link
Author

All good, hope it gets merged soon 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants