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

Unexpected value 'FeatherModule' when developing unit tests #57

Open
spoilerdo opened this issue Feb 23, 2022 · 1 comment
Open

Unexpected value 'FeatherModule' when developing unit tests #57

spoilerdo opened this issue Feb 23, 2022 · 1 comment

Comments

@spoilerdo
Copy link

Trying to make unit tests for my components that use . For this to work I need to import the FeatherModule. But when running the unit tests I keep getting the following error:

Unexpected value 'FeatherModule' imported by the module 'DynamicTestModule'. Please add an @NgModule annotation.

      at verifySemanticsOfNgModuleDef (../packages/core/src/render3/jit/module.ts:200:13)
      at ../packages/core/src/render3/jit/module.ts:211:5
          at Array.forEach (<anonymous>)
      at verifySemanticsOfNgModuleDef (../packages/core/src/render3/jit/module.ts:209:58)
      at Function.get (../packages/core/src/render3/jit/module.ts:169:13)
      at R3TestBedCompiler.Object.<anonymous>.R3TestBedCompiler.applyProviderOverridesToModule (../packages/core/testing/src/r3_test_bed_compiler.ts:414:49)
      at R3TestBedCompiler.Object.<anonymous>.R3TestBedCompiler.compileTestModule (../packages/core/testing/src/r3_test_bed_compiler.ts:677:10)
      at R3TestBedCompiler.Object.<anonymous>.R3TestBedCompiler.finalize (../packages/core/testing/src/r3_test_bed_compiler.ts:245:10)
      at TestBedRender3.get (../packages/core/testing/src/r3_test_bed.ts:380:43)
      at TestBedRender3.Object.<anonymous>.TestBedRender3.inject (../packages/core/testing/src/r3_test_bed.ts:278:25)
      at TestBedRender3.Object.<anonymous>.TestBedRender3.createComponent (../packages/core/testing/src/r3_test_bed.ts:335:40)
      at Function.Object.<anonymous>.TestBedRender3.createComponent (../packages/core/testing/src/r3_test_bed.ts:182:33)
      at projects/pig-settings-library/src/lib/components/employee/employee.component.spec.ts:69:23
      at ZoneDelegate.Object.<anonymous>.ZoneDelegate.invoke (node_modules/zone.js/bundles/zone-testing-bundle.umd.js:407:30)
      at ProxyZoneSpec.Object.<anonymous>.ProxyZoneSpec.onInvoke (node_modules/zone.js/bundles/zone-testing-bundle.umd.js:3765:43)
      at ZoneDelegate.Object.<anonymous>.ZoneDelegate.invoke (node_modules/zone.js/bundles/zone-testing-bundle.umd.js:406:56)
      at Zone.Object.<anonymous>.Zone.run (node_modules/zone.js/bundles/zone-testing-bundle.umd.js:167:47)
      at Object.wrappedFunc (node_modules/zone.js/bundles/zone-testing-bundle.umd.js:4250:34)

I also tried to add a IconModule and import that one to my unit test but got the same result.

This is my Unit test setup code:

  let component: EmployeeComponent;
  let fixture: ComponentFixture<EmployeeComponent>;

  beforeEach(async () => {
    await TestBed.configureTestingModule({
      declarations: [EmployeeComponent, DataGridComponent, CustomLoadingComponent],
      imports: [CommonModule, AgrovisionAngularSharedModule, HttpClientTestingModule, IconsModule, ...materialModules],
      providers: [
        { provide: EmployeeService, useValue: mockEmployeeService },
        { provide: ColumnBuilderService, useValue: mockColumnBuilderService },
        { provide: TranslationService, useValue: mockTranslationService },
      ],
    }).compileComponents();
  });

  beforeEach(() => {
    fixture = TestBed.createComponent(EmployeeComponent);
    component = fixture.componentInstance;
    fixture.detectChanges();
  });

Currently using version 6.2.0 because 6.3.0 is not working for me cause of my Angular version.
Anyone know a solution for this?

@AurelienLoyer
Copy link

+1 same issue here, moving to version 6.3.0

image

I'm currently in Angular 12.x , i will be back with more information after the migration, it look like version 6.3.0 have been introduce for Angular 13+

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