Skip to content

Unit tests run with --bundle does not bundle 3rd party libraries #4477

Closed
@cowboyd

Description

@cowboyd

Environment
✔ Getting NativeScript components versions information...
✔ Component nativescript has 5.4.0-2019-03-21-13075 version and is up to date.
✔ Component tns-core-modules has 5.3.0 version and is up to date.
✔ Component tns-android has 5.3.0 version and is up to date.
✔ Component tns-ios has 5.3.0 version and is up to date.

Describe the bug
Webpack test bundle does not include 3rd party libraries. We're trying to unit test some of our library code that uses the @microstates/union. This works when the app is built, but when we try to run the unit tests, they fail with the error:

TypeError: undefined is not an object (evaluating 'modules[moduleId].call')

Which indicates that the microstate library is not bundled at all. Manually inspecting the built vendor.js, and bundle.js confirms that this is the case.

To Reproduce

  1. import a 3rd party library from within a unit test case. You don't even have to try and use it, just log it to the console.
  2. run yarn test ios --bundle

Expected behavior

  1. it resolves the module and dependencies from the node_modules directory and includes it in your application's vendor.js bundle.
  2. in this case, it should have the microstates and @microstates/union modules since they are being imported by our bluetooth library.

Sample project

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions