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

tns test command cannot work if the source is not in src directory #5070

Closed
Fatme opened this issue Oct 14, 2019 · 3 comments
Closed

tns test command cannot work if the source is not in src directory #5070

Fatme opened this issue Oct 14, 2019 · 3 comments
Assignees
Milestone

Comments

@Fatme
Copy link
Contributor

Fatme commented Oct 14, 2019

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.

@Fatme Fatme added the bug label Oct 14, 2019
@Fatme Fatme self-assigned this Oct 14, 2019
@Fatme Fatme added this to the 6.2.0 milestone Oct 14, 2019
Fatme added a commit that referenced this issue Oct 14, 2019
Two different webpack compilations are started on `tns test` command - the one from `karma-webpack` and the second one from `nativescript-dev-webpack`. As the karma's webpack doesn't provide appPath to the env and there is a hardcoded `appPath` inside `webpack.config.js` (to `src` for example), it works only with that hardcoded path.

Rel to: #5070
Fatme added a commit that referenced this issue Oct 14, 2019
Two different webpack compilations are started on `tns test` command - the one from `karma-webpack` and the second one from `nativescript-dev-webpack`. As the karma's webpack doesn't provide appPath to the env and there is a hardcoded `appPath` inside `webpack.config.js` (to `src` for example), it works only with that hardcoded path.

Rel to: #5070
@jevenson
Copy link

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

@Fatme
Copy link
Contributor Author

Fatme commented Oct 24, 2019

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.

@Fatme
Copy link
Contributor Author

Fatme commented Oct 24, 2019

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

env.appPath = config.appPath;

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

3 participants