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 'KernelModule' imported by the module 'DynamicTestModule' #3463

Closed
avril-verhaeghen opened this issue Dec 8, 2016 · 9 comments
Labels
needs: more info Reporter must clarify the issue

Comments

@avril-verhaeghen
Copy link

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.

@hansl
Copy link
Contributor

hansl commented Dec 8, 2016

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

@hansl hansl added the needs: more info Reporter must clarify the issue label Dec 8, 2016
@serhiisol
Copy link
Contributor

serhiisol commented Jan 12, 2017

@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.

@blingwang
Copy link

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)
        })
      ]
    },

@izoomi
Copy link

izoomi commented Feb 14, 2017

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

@chaosmonster
Copy link

what is the status on this issue?

@avril-verhaeghen
Copy link
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.

@filipesilva
Copy link
Contributor

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

@AlexKhymenko
Copy link

@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

@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs: more info Reporter must clarify the issue
Projects
None yet
Development

No branches or pull requests

8 participants