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

CUSTOM_ELEMENTS_SCHEMA is ignored for WebComponents #4228

Closed
MatthieuNarcisi opened this issue Nov 15, 2022 · 5 comments · Fixed by #4304
Closed

CUSTOM_ELEMENTS_SCHEMA is ignored for WebComponents #4228

MatthieuNarcisi opened this issue Nov 15, 2022 · 5 comments · Fixed by #4304

Comments

@MatthieuNarcisi
Copy link

We are trying to use the modern MockBuilder to mock a component and its module.

The component makes use of WebComponents (developed via StencilJS).

When trying to add the CUSTOM_ELEMENTS_SCHEMA token with the method beforeCompileComponents, I still have the error in the console that the CUSTOM_ELEMENTS_SCHEMA token should be defined.

There is how to reproduce the issue : https://stackblitz.com/edit/github-yynxfc?file=src%2Ftest.spec.ts (the error appears in the console).

image

When using the classic way of doing things (via TestBed), I don't have any issue : https://stackblitz.com/edit/github-yzyftf?file=src%2Ftest.spec.ts

Any idea of what I might be doing wrong ?

@satanTime
Copy link
Member

satanTime commented Nov 19, 2022

Hi @MatthieuNarcisi,

thank you for the report.

Do I understand correctly that you don't import custom-component anywhere in your app?

@NgModule({
  imports: [CommonModule],
  declarations: [TargetComponent],
  schemas: [CUSTOM_ELEMENTS_SCHEMA],
})
class TargetModule {}

I found out that it will work like that, but not sure if it's something what would suite you.

Could you try this build in your app? ng-mocks.zip

@MatthieuNarcisi
Copy link
Author

Hi, thank you. It is exactly that, as custom-component is a WebComponent, it cannot be imported as an Angular component or part of a module (as stated in the second point of the error message).

I will try the build tomorrow and give you feedback as soon as possible.

@MatthieuNarcisi
Copy link
Author

Hi @satanTime,

Getting back to you, I could test the zip you provided me today and it is working perfectly.

Thank you for all your outstanding work !

@satanTime
Copy link
Member

Great. I'll release it asap.

@satanTime
Copy link
Member

v14.3.4 has been released and contains a fix for the issue. Feel free to reopen the issue or to submit a new one if you meet any problems.

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

Successfully merging a pull request may close this issue.

2 participants