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

Standalone Directives not mocked correctly #242

Closed
attrobit opened this issue May 15, 2023 · 3 comments
Closed

Standalone Directives not mocked correctly #242

attrobit opened this issue May 15, 2023 · 3 comments

Comments

@attrobit
Copy link
Contributor

attrobit commented May 15, 2023

When we import an standalone directive, the following error occurs:

Error: "StandaloneDirective" does not have a module def (ɵmod property)

The following unit tests reproduces the bug:

import {Component, Directive, NgModule} from '@angular/core';
import {Shallow} from '../shallow';

@Directive({
  standalone: true,
  selector: 'my-standalone-directive',
})
class MyStandaloneDirective {
}

@Component({
  selector: 'my-component',
  template: '<div my-standalone-directive></div>',
})
class MyComponent {}

@NgModule({
  declarations: [MyComponent],
  // Import the Standalone directive directly into the module
  imports: [MyStandaloneDirective],
})
class ModuleWithStandalone {}

describe('standalone component imported in a module', () => {
  let shallow: Shallow<ModuleWithStandalone>;

  beforeEach(() => {
    shallow = new Shallow(MyComponent, ModuleWithStandalone);
  });

  it('should be mocked', async () => {
    await shallow.render();
  });
});
attrobit pushed a commit to attrobit/shallow-render that referenced this issue May 15, 2023
attrobit pushed a commit to attrobit/shallow-render that referenced this issue May 15, 2023
@floisloading
Copy link

We're having the same issue here (using NgOptimizedImage)

@attrobit
Copy link
Contributor Author

We're having the same issue here (using NgOptimizedImage)

If fixed it and created already a pr.

getsaf pushed a commit that referenced this issue May 16, 2023
Co-authored-by: Philipp Lang <philipp.lang@egroup-extern.ch>
@getsaf
Copy link
Owner

getsaf commented May 16, 2023

Thanks @attrobit for the fix. PR was merged and I just published v15.0.3!

@getsaf getsaf closed this as completed May 16, 2023
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

3 participants