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

Bug(transloco): Unknown components wrapped within Transloco structural directive do not throw in unit tests #707

Open
1 task done
joonashak opened this issue Sep 25, 2023 · 3 comments

Comments

@joonashak
Copy link
Contributor

Is there an existing issue for this?

  • I have searched the existing issues

Which Transloco package(s) are the source of the bug?

Transloco

Is this a regression?

No

Current behavior

Unit testing does not fail on unknown components if a parent component includes the *transloco="let t" structural directive.

Steps to reproduce:

  1. Create a component that wraps an unknown component (I used <child>)within a parent that uses Transloco's structural directive (I used <ng-container *transloco="let t">.
  2. Unit test the component, using the { errorOnUnknownElements: true } option.
  3. The unit test should fail with Error: NG0304: 'child' is not a known element (used in the 'Test1Component' component template).
  4. To see the test fail, remove the structural directive. Note that there is no need to actually use the t function anywhere.

You can also reproduce the bug by cloning the linked example repo, running npm ci, and then npm run test1 to run a test that fails correctly, or npm run test2 to run a test where Transloco causes it to pass when it should fail like the first one. Note that the main branch uses Angular 15 because we originally discovered the bug with that version. There is also ng16 branch that implements the same example with Angular 16 and Transloco 6.

Expected behavior

Using errorOnUnknownElements should throw NG0304 even when wrapped in the Transloco structural directive.

Please provide a link to a minimal reproduction of the bug, if you won't provide a link the issue won't be handled.

https://github.com/funidata/ng-unit-test-debug

Transloco Config

No response

Please provide the environment you discovered this bug in

Transloco: 4.2.6 || 6.0.0
Angular: 15.2.9 || 16.2.6
Node: 18.18
Package Manager: npm@9.8.1
OS: macOS 13.5.2

Browser

No response

Additional context

No response

I would like to make a pull request for this bug

No

@joonashak
Copy link
Contributor Author

joonashak commented Sep 25, 2023

Actually, this might be an older problem with Angular itself. See angular/angular#37322 .

If you think this is the case, feel free to close this issue :)

EDIT: On a second thought, maybe not. The linked issue seems to be about missing directives rather than missing components. Might be related though.

@shaharkazaz
Copy link
Collaborator

@joonashak Please update the title.

@joonashak joonashak changed the title Bug(scope): Bug(transloco): Unknown components wrapped within Transloco structural directive do not throw in unit tests Sep 26, 2023
@joonashak
Copy link
Contributor Author

Sorry, totally missed the title 🙈

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

No branches or pull requests

2 participants