NativeScript / nativescript-dev-webpack

A package to help with webpacking NativeScript apps.
Apache License 2.0
97 stars 49 forks source link

Test files are always included in the built application #1041

Closed rosen-vladimirov closed 4 years ago

rosen-vladimirov commented 4 years ago

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):


 - 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.