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

On adding test frameworks their peerDependencies are not installed #2283

Closed
pkoleva opened this issue Nov 30, 2016 · 8 comments
Closed

On adding test frameworks their peerDependencies are not installed #2283

pkoleva opened this issue Nov 30, 2016 · 8 comments
Assignees
Milestone

Comments

@pkoleva
Copy link
Contributor

pkoleva commented Nov 30, 2016

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

@pkoleva pkoleva added the bug label Nov 30, 2016
@Plamen5kov
Copy link
Contributor

Plamen5kov commented Nov 30, 2016

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)

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

@NickIliev
Copy link
Contributor

related to #2212 (comment)

@tsonevn tsonevn added this to the 2.6.0 (TBD) milestone Dec 5, 2016
@pkoleva pkoleva modified the milestone: 2.6.0 (TBD) Jan 26, 2017
@vakrilov
Copy link

vakrilov commented Mar 8, 2017

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.

@dtopuzov
Copy link
Contributor

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

dtopuzov added a commit to NativeScript/nativescript-cli-tests that referenced this issue Apr 25, 2017
@dtopuzov
Copy link
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

@rosen-vladimirov
Copy link
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).

@NickIliev
Copy link
Contributor

The issue is still reproducible .. running

tns test init --framework mocha
tns test ios

is failing with

Error: Cannot find module 'mocha'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants