0

After upgrading to Angular 10, I am having issues running the libraries' unit tests.

I have two project libraries. For example LibTest1 HeroTest2

HeroTest2 consumes LibTest1

Project tsconfig.json contains

{
    .......
    "baseUrl": "./",
     .....
    "paths": {
      "LibtTest1": [
        "dist/LibTest1"
      ],
      "LibTest1/*": [
        "dist/LibTest1/*"
      ],
      "HeroTest2": [
        "dist/HeroTest2"
      ],
      "HeroTest2/*": [
        "dist/HeroTest2/*"
      ]
    }
  }
}

Project library HeroTest2 tsconfig.lib.json contains

"
{
   extends": "../../tsconfig.json",
   .....
}

Project library HeroTest2 tsconfig.spec.json contains

"
{
   extends": "../../tsconfig.json",
   .....
}

Project library HeroTest2 package.json contains

{
   "name": "HeroTest2",
   .....
   "dependencies": {
    "LibTest1": "*",
    "tslib": "^2.0.0"
  },
  .....
}

I am importing LibTest1 exported modules in HeroTest2 as

import {someModuleFromLibTest1} from 'LibTest1';

There are no issues when I build the libraries and run the app. HeroTest2 recognizes LibTest1 and builds fine.

In unit tests of HeroTest2 , I have added the module from LibTest1

import {someModuleFromLibTest1} from 'LibTest1';
.....
beforeEach(async(() => {
    TestBed.configureTestingModule({
      declarations: [ .... ],
      imports: [...., someModuleFromLibTest1, ...]
    })
    .compileComponents();
  }));
....

Getting the following error when I run unit tests for HeroTest2

Error: Unexpected value 'someModuleFromLibTest1' imported by the module 'DynamicTestModule'. Please add an @NgModule annotation.

Any help would be appreciated.

1 Answers1

0

Try deleting your node_modules folder and rerun npm install, might be some inconsistencies in the node modules after your upgrade.