Skip to content

Unexpected value 'KernelModule' imported by the module 'DynamicTestModule' #3463

Closed

Description

@avril-verhaeghen

Please provide us with the following information:

OS?

Windows 7, 8 or 10. Linux (which distribution). Mac OSX (Yosemite? El Capitan?)
Windows 7

Versions.

Please run ng --version. If there's nothing outputted, please run in a Terminal: node --version and paste the result here:

$ ng version
angular-cli: 1.0.0-beta.21
node: 6.4.0
os: win32 x64
$ node version
v6.4.0

Repro steps.

Was this an app that wasn't created using the CLI? What change did you do on your code? etc.
Added custom components and custom routings

The log given by the failure.

Chrome 54.0.2840 (Windows 7 0.0.0) Page partenaire list should test true is true FAILED
Failed: Unexpected value 'KernelModule' imported by the module 'DynamicTestModule'
Error: Unexpected value 'KernelModule' imported by the module 'DynamicTestModule'
at webpack:///C:/Develop/partenaire-front-end//@angular/compiler/src/metadata_resolver.js:363:0 <- src/test.ts:26654:31
at Array.forEach (native)
at CompileMetadataResolver._loadNgModuleMetadata (webpack:///C:/Develop/partenaire-front-end/
/@angular/compiler/src/metadata_resolver.js:348:0 <- src/test.ts:26639:49)
at CompileMetadataResolver.loadNgModuleMetadata (webpack:///C:/Develop/partenaire-front-end//@angular/compiler/src/metadata_resolver.js:313:0 <- src/test.ts:26604:29)
at RuntimeCompiler._loadModules (webpack:///C:/Develop/partenaire-front-end/
/@angular/compiler/src/runtime_compiler.js:99:0 <- src/test.ts:43055:41)
at RuntimeCompiler._compileModuleAndAllComponents (webpack:///C:/Develop/partenaire-front-end//@angular/compiler/src/runtime_compiler.js:83:0 <- src/test.ts:43039:35)
at RuntimeCompiler.compileModuleAndAllComponentsAsync (webpack:///C:/Develop/partenaire-front-end/
/@angular/compiler/src/runtime_compiler.js:65:0 <- src/test.ts:43021:21)
at TestingCompilerImpl.compileModuleAndAllComponentsAsync (webpack:///C:/Develop/partenaire-front-end//@angular/compiler/bundles/compiler-testing.umd.js:485:0 <- src/test.ts:65925:35)
at TestBed.compileComponents (webpack:///C:/Develop/partenaire-front-end/
/@angular/core/bundles/core-testing.umd.js:745:0 <- src/test.ts:14955:35)
at Function.TestBed.compileComponents (webpack:///C:/Develop/partenaire-front-end/~/@angular/core/bundles/core-testing.umd.js:648:49 <- src/test.ts:14858:71)
Chrome 54.0.2840 (Windows 7 0.0.0): Executed 1 of 1 (1 FAILED) ERROR (0.159 secs / 0.019 secs)

Mention any other details that might be useful.

The KernelModule is for the moment a custom made Angular2 webpack app that we host on Bitbucket, so it's being installed by the other app which is now an angular-cli app. And there I want to perform my UT. This KernelModule will be migrated in the near future to angular-cli too.

The meaning behind KernelModule is that it will share other component.

Metadata for this one is:

@NgModule({
  imports: [
    CommonModule,
    FormsModule,
    BrowserModule,
    ReactiveFormsModule,

    /**
     * KendoUI Modules
     */
    GridModule
  ],
  declarations: [
    KernelBoxComponent,

    /**
     * Based on KendoUI
     */
    KernelTableComponent,
    KernelTableHeaderComponent
  ],
  exports: [
    CommonModule,
    FormsModule,
    BrowserModule,
    ReactiveFormsModule,

    KernelBoxComponent,

    /**
     * Based on KendoUI
     */
    KernelTableComponent,
    KernelTableHeaderComponent
  ]
})

I'm guessing that it could be either because the KernelModule is not build correctly, or (but this is a long shot) KernelModule is for now webpack? I'm thinking about these because once I copied the KernelBoxComponent and pasted into my project and used the component directly instead of the module, there wasn't a problem for doing my tests. BUT when I used the component directly from the my custom made webpack app, then I got other errors.


Thanks! We'll be in touch soon.

Activity

  1. hansl commented on Dec 8, 2016

    @hansl
    Contributor

    What is DynamicTestModule? It seems you're missing imports or something.

  2. serhiisol commented on Jan 12, 2017

    @serhiisol
    Contributor

    @hansl DynamicTestModule is a part of Angular testing bed.

    I have the same problem, when I'm trying to import 3d party modules from node_modules and trying to test my services.

  3. blingwang commented on Jan 28, 2017

    @blingwang

    I used local npm linked lib and got a similar issue like this. The package versions in my project:

    angular-cli: 1.0.0-beta.26
    node: 6.2.1
    os: darwin x64
    @angular/common: 2.4.5
    @angular/compiler: 2.4.5
    @angular/core: 2.4.5
    @angular/forms: 2.4.5
    @angular/http: 2.4.5
    @angular/platform-browser: 2.4.5
    @angular/platform-browser-dynamic: 2.4.5
    @angular/router: 3.4.5
    

    The error is:
    Unexpected value 'MyCustomLibraryModule' imported by the module 'DynamicTestModule'
    The root cause of this issue seems to be webpack cannot find the lib module with its resolve rules.
    I solved the issue by editing resolve rules in the webpack config file node_modules/angular-cli/models/webpack-build-test.js:

      resolve: {
          extensions: ['.ts', '.js'],
          modules: [path.resolve(projectRoot, 'node_modules')],
          plugins: [
            new ngtools.PathsPlugin({
              tsConfigPath: path.resolve(appRoot, appConfig.tsconfig)
            })
          ]
        },
    
  4. izoomi commented on Feb 14, 2017

    @izoomi

    Same issue when running tests. @blingwang's solution fixes the problem.

  5. chaosmonster commented on Feb 27, 2017

    @chaosmonster

    what is the status on this issue?

  6. avril-verhaeghen commented on Apr 6, 2017

    @avril-verhaeghen
    Author

    @chaosmonster this issue is fixed meanwhile. But if I remember correctly I had to add
    schemas: [ CUSTOM_ELEMENTS_SCHEMA ]
    in the metadata for configuring my test module.

  7. filipesilva commented on May 22, 2017

    @filipesilva
    Contributor

    Closing as outdated. If this still happens, please let me know.

  8. AlexKhymenko commented on Jan 22, 2018

    @AlexKhymenko

    @filipesilva Have the same issue again

    @angular/cli: 1.6.5
    @angular-devkit/build-optimizer: 0.0.41
    @angular-devkit/core: 0.0.28
    @angular-devkit/schematics: 0.0.51
    @ngtools/json-schema: 1.1.0
    @schematics/angular: 0.1.16
    typescript: 2.5.3
    webpack: 3.10.0

  9. angular-automatic-lock-bot commented on Sep 7, 2019

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  10. locked and limited conversation to collaborators on Sep 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions