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

How to mock a dynamically imported standalone component inside a standalone component #4742

Closed
satanTime opened this issue Jan 21, 2023 Discussed in #4693 · 1 comment · Fixed by #4743
Closed

How to mock a dynamically imported standalone component inside a standalone component #4742

satanTime opened this issue Jan 21, 2023 Discussed in #4693 · 1 comment · Fixed by #4743

Comments

@satanTime
Copy link
Member

satanTime commented Jan 21, 2023

Discussed in #4693

Originally posted by AE1NS January 13, 2023
Hey,

I have two standalone components, Test1Component and Test2Component. Test1Component dynamically imports Test2Component import(Test2Component).then(.... Is there a way to get a mocked version of Test2Component?

beforeEach(() => {
    return MockBuilder(Test1Component).mock(Test2Component, { shallow: true });
});

as the docs says, this mocks only the imports and thats working as expected, but how can I mock the component itself and ignore its imports? This also does not work and also seem to just mock the imports but everytime, my implementation is called (tested it with a console.log):

beforeEach(() => {
    return MockBuilder(Test1Component).mock(Test2Component, { shallow: false });
});
satanTime added a commit that referenced this issue Jan 21, 2023
feat(core): ViewContainerRef.createComponent respects mocks #4742
@satanTime
Copy link
Member Author

v14.6.0 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.

1 participant