Skip to content
This repository was archived by the owner on Aug 7, 2021. It is now read-only.
This repository was archived by the owner on Aug 7, 2021. It is now read-only.

Test files are always included in the built application #1041

Closed
@rosen-vladimirov

Description

@rosen-vladimirov

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.0
  • Cross-platform modules: 6.1.0
  • Android Runtime: 6.1.0
  • iOS Runtime: 6.1.0
  • Plugin(s):
{
  "nativescript": {
    "id": "org.nativescript.app1",
    "tns-android": {
      "version": "6.1.0"
    },
    "tns-ios": {
      "version": "6.1.0"
    }
  },
  "description": "NativeScript Application",
  "license": "SEE LICENSE IN <your-license-filename>",
  "repository": "<fill-your-repository-here>",
  "dependencies": {
    "nativescript-theme-core": "~1.0.6",
    "nativescript-unit-test-runner": "^0.7.0",
    "tns-core-modules": "~6.1.0"
  },
  "devDependencies": {
    "chai": "4.2.0",
    "karma": "4.3.0",
    "karma-chai": "0.1.0",
    "karma-mocha": "1.3.0",
    "karma-nativescript-launcher": "0.4.0",
    "karma-webpack": "3.0.5",
    "mocha": "6.2.0",
    "nativescript-dev-webpack": "~1.2.0"
  },
  "gitHead": "9475c272a4c74ea6baf24d578bdf46c23a400fea",
  "readme": "NativeScript Application"
}
  • Node.js: 10.15.3

Describe the bug
Files with unit tests (located in <project dir>/<app dir>/test are always included in the built application, no matter if tns run or tns test is executed. This increases the size of application as there might be a lot of dev dependencies included in the unit test (for example chai).

To Reproduce

  1. Create a new app: tns create app1 --js
  2. Navigate to it: cd app1
  3. Initialize tests, for example with mocha framework: tns test init --framework mocha
  4. Open the generate example.js file and add the following line at the top: const chai = require("chai"); (NOTE: This step is just to show that chai will be included in the built application, you can verify only example.js in step 6)
  5. Run tns prepare android - this should not include any test files in the bundle.js
  6. Check the generated bundle.js and vendor.js in the platforms directory:
  • check the bundle.js - it shouldn't contain any reference to example.js file - in fact it has it
  • check the vendor.js - it shouldn't contain any reference to chai - in fact it has it.

Expected behavior
Unit test files and testing dependencies should be included only when tns test <platform> command is executed.

Additional context
This is working correctly in versions prior to 6.0.0.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions