NativeScript / NativeScript/nativescript-cli

test init messes up project

Open
#5,396 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
1.1k
Forks
204
Avg merge
1d 9h
Merged PRs (30d)
8

Description

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):
✔ Getting NativeScript components versions information...
✔ Component nativescript has 7.0.8 version and is up to date.
✔ Component @nativescript/core has 7.0.3 version and is up to date.
✔ Component @nativescript/ios has 7.0.0 version and is up to date.
✖ Component @nativescript/android is not installed.

Describe the bug
Trying to run unit tests fails with the following error:

Error: Cannot use import statement outside a module
    at Errors.failWithOptions (/usr/local/lib/node_modules/nativescript/lib/common/errors.js:157:27)
    at Errors.fail (/usr/local/lib/node_modules/nativescript/lib/common/errors.js:130:21)
    at DevicesService.<anonymous> (/usr/local/lib/node_modules/nativescript/lib/common/mobile/mobile-core/devices-service.js:425:30)
    at Generator.throw (<anonymous>)
    at rejected (/usr/local/lib/node_modules/nativescript/lib/common/mobile/mobile-core/devices-service.js:12:65)
    at processTicksAndRejections (internal/process/task_queues.js:97:5) {
  name: 'Exception',
  errorCode: 127,
  suggestCommandHelp: false,
  proxyAuthenticationRequired: false,
  printOnStdout: undefined
}

To Reproduce

tns create demo-test --tsc
tns test init #select mocha
tns test ios

Expected behavior
Tests to run.

Sample project

Additional context

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure with tns create demo-test --tsc, tns test init, and tns test ios, then inspect the CLI path reported in lib/common/mobile/mobile-core/devices-service.js. Trace how the Mocha test setup is initialized and determine what must change so the generated TypeScript project runs its iOS tests without the import error.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
cli, testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.