Skip to content

On adding test frameworks their peerDependencies are not installed #2283

Closed

Description

@pkoleva

Steps to reproduce:

  1. Create app and add platform
  2. tns test init --framework jasmine/mocha
  3. tns test android/ios

Expected result: Tests are executes and results are shown
Actual result: Exception Error: Cannot find module 'jasmine-core'...

Activity

  1. Plamen5kov commented on Nov 30, 2016

    @Plamen5kov
    Contributor

    Problem

    Only occurs when the user has installed globally npm version 3.x. The difference between npm 2.x and 3.x is that, npm 2.x installs all peer-dependencies of a package and npm 3.x does not.
    Example: lets install the following package with package.json like:

    {
      "name": "some-dependency",
      "version": "1.0.0",
      "peer-dependencies": {
        "peer-dep-1": "0.0.1"
      }
    }

    So if we do:
    npm install some-dependency --save with npm 2.x, peer-dep-1 will be installed, but if we do the same with npm 3.x peer-dep-1 will not be installed. This happens, because npm 3.x does not install the peer-dependencies.

    Possible solutions

    • Forcefully install the peer dependencies of all packages when using tns init command. When doing it with npm 2.x, nothing will happen.
    • Add missing peer dependency to tns init command (harder to maintain)
    • fix in package (move from peer-dependency to dependency)
  2. petekanev commented on Nov 30, 2016

    @petekanev
    Contributor

    @Plamen5kov how about leaving the responsibility of installing dev peer dependencies to the developer? Messages output by npm are verbose enough where peer dependencies are concerned.

  3. NickIliev commented on Nov 30, 2016

    @NickIliev

    related to #2212 (comment)

  4. added this to the milestone on Dec 5, 2016
  5. modified the milestone: on Jan 26, 2017
  6. vakrilov commented on Mar 8, 2017

    @vakrilov

    I think that after seeing the message about the unmet peer dependency -its clear what you have to do. However, it would be great to update the docs with a note that you will have to manually add a dependency based on the testing framework you choose. It would help people who just follow the guide.

    @Pip3r4o moving peer-dependecy to dependency is out of our reach, as it is the karma-jamine package that has the peer-dep.

  7. dtopuzov commented on Apr 25, 2017

    @dtopuzov
    Contributor

    #2693 fix jasmin and qunit successfully, but you still need to manually install mocha.

  8. dtopuzov commented on Apr 25, 2017

    @dtopuzov
    Contributor

    CLI is now adding peer dependencies, but the problem is that mocha is not longer peer dependency.
    May be we should close the issue add some notes here:
    https://docs.nativescript.org/tooling/testing#configure-your-project

  9. rosen-vladimirov commented on Apr 26, 2017

    @rosen-vladimirov
    Contributor

    I believe the $ tns test init command should provide a project that's ready for writing tests, without the need to install any dependencies additionally. We can improve our logic here:
    https://github.com/NativeScript/nativescript-cli/blob/master/lib/commands/test-init.ts#L7-L9
    https://github.com/NativeScript/nativescript-cli/blob/master/lib/commands/test-init.ts#L32-L33

    To add the required depdendencies (as mocha).

  10. NickIliev commented on May 15, 2018

    @NickIliev

    The issue is still reproducible .. running

    tns test init --framework mocha
    tns test ios
    

    is failing with

    Error: Cannot find module 'mocha'
    
  11. added this to the 4.1.2 milestone on Jun 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions