Nativescript-cli: `tns test` command cannot work if the source is not in `src` directory

Created on 14 Oct 2019  路  3Comments  路  Source: NativeScript/nativescript-cli

Environment
Provide version numbers for the following components (information can be retrieved by running tns info in your project folder or by inspecting the package.json of the project):

  • CLI: 6.1.x
  • Cross-platform modules:
  • Android Runtime:
  • iOS Runtime:
  • Plugin(s):

Describe the bug
Currently tns test command throws the following error in case when source code is not in src directory:

10 10 2019 11:34:38.105:ERROR [config]: Error in config file!
 Error: The specified path to app directory /Users/havaluova/Work/sample-Groceries/src does not exist. Unable to find entry module.
    at verifyEntryModuleDirectory (/Users/havaluova/Work/sample-Groceries/node_modules/nativescript-dev-webpack/index.js:163:15)
    at Object.exports.getEntryModule (/Users/havaluova/Work/sample-Groceries/node_modules/nativescript-dev-webpack/index.js:29:5)
    at module.exports.env (/Users/havaluova/Work/sample-Groceries/webpack.config.js:60:38)
    at setWebpack (/Users/havaluova/Work/sample-Groceries/karma.conf.js:102:50)
    at module.exports (/Users/havaluova/Work/sample-Groceries/karma.conf.js:77:3)
    at Object.parseConfig (/Users/havaluova/Work/sample-Groceries/node_modules/karma/lib/config.js:393:5)
    at new Server (/Users/havaluova/Work/sample-Groceries/node_modules/karma/lib/server.js:66:24)
    at process.on (/Users/havaluova/Work/nativescript-cli/lib/services/karma-execution.js:6:160)
    at process.emit (events.js:182:13)
    at emit (internal/child_process.js:812:12)
    at process._tickCallback (internal/process/next_tick.js:63:19)
Test run failed.

To Reproduce
There are 2 options to reproduce the issue:

Option 1:

  1. Clone https://github.com/NativeScript/sample-Groceries
  2. npm i && tns test ios

Option 2:

  1. Create new angular project
  2. Rename src to src1
  3. Change appPath to src1 inside nsconfig.json
  4. tns test ios

Expected behavior
The unit tests should be successfully executed.

bug unit testing

Most helpful comment

Actually just updating CLI will not fix the problem if you have already executed tns test init command in your application. In such a situation, you need to manually include this change inside karma.config.js

https://github.com/NativeScript/nativescript-cli/blob/e75acf8f54051cd83a12615486cd4ddc455cd060/resources/test/karma.conf.js#L102

All 3 comments

Is this change available with a "next" version of the CLI on npm? When will it be available in latest?

Hey @jevenson,

The change is available in the rc version of the CLI. You can install it using npm i -g nativescript@rc. It'll be available officially in the next minor release of NativeScript which is planned in a few weeks.

Actually just updating CLI will not fix the problem if you have already executed tns test init command in your application. In such a situation, you need to manually include this change inside karma.config.js

https://github.com/NativeScript/nativescript-cli/blob/e75acf8f54051cd83a12615486cd4ddc455cd060/resources/test/karma.conf.js#L102

Was this page helpful?
0 / 5 - 0 ratings

Related issues

DimitarTachev picture DimitarTachev  路  3Comments

charsleysa picture charsleysa  路  3Comments

PeterStaev picture PeterStaev  路  3Comments

NickIliev picture NickIliev  路  3Comments

kefahB picture kefahB  路  3Comments