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: MockBuilder doesn't detect kept modules in standalone components #5520

Closed
satanTime opened this issue Apr 22, 2023 · 1 comment · Fixed by #5529
Closed

Bug: MockBuilder doesn't detect kept modules in standalone components #5520

satanTime opened this issue Apr 22, 2023 · 1 comment · Fixed by #5529
Assignees
Labels
bug Something isn't working released v14.10.0

Comments

@satanTime
Copy link
Member

satanTime commented Apr 22, 2023

import { Component, NgModule } from '@angular/core';
import { MockBuilder, MockRender } from 'ng-mocks';

@Component({
  selector: 'my-component',
  template: '',
})
class MyComponent {}

@NgModule({
  declarations: [MyComponent],
  exports: [MyComponent],
})
class MyModule {}

@Component({
  selector: 'my-standalone-component',
  standalone: true,
  template: '',
  imports: [MyModule],
})
class MyStandaloneComponent {}

beforeEach(() => MockBuilder(MyStandaloneComponent, null).keep(MyModule).mock(MyComponent));
// Error: MockBuilder has found a missing dependency: MyModule. It means no module provides it.
// Please, use the "export" flag if you want to add it explicitly. https://ng-mocks.sudo.eu/api/MockBuilder#export-flag

it('creates MyStandaloneComponent', () => {
  expect(() => MockRender(MyStandaloneComponent)).not.toThrow();
});
@satanTime satanTime added the bug Something isn't working label Apr 22, 2023
@satanTime satanTime self-assigned this Apr 22, 2023
satanTime added a commit that referenced this issue Apr 23, 2023
fix(MockBuilder): touches kept modules in standalone components #5520
@satanTime
Copy link
Member Author

v14.10.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
Labels
bug Something isn't working released v14.10.0
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant