Steps to reproduce:
Expected result: Tests are executes and results are shown
Actual result: Exception Error: Cannot find module 'jasmine-core'...
_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_
tns init command. When doing it with npm 2.x, nothing will happen.tns init command (harder to maintain)peer-dependency to dependency)@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.
related to https://github.com/NativeScript/nativescript-cli/issues/2212#issuecomment-263877510
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.
https://github.com/NativeScript/nativescript-cli/pull/2693 fix jasmin and qunit successfully, but you still need to manually install mocha.
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
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).
The issue is still reproducible .. running
tns test init --framework mocha
tns test ios
is failing with
Error: Cannot find module 'mocha'
Most helpful comment
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-dependecytodependencyis out of our reach, as it is thekarma-jaminepackage that has the peer-dep.