node package manager
Easy collaboration. Discover, share, and reuse code in your team. Create a free org ยป



npm (scoped)

DEPRECATED: This project has been deprecated. Because core modules have been published to the public NPM, this project no longer provides value.

A Webpack loader for injecting Turbine core modules into Launch extension library modules while testing.

For more information regarding Launch, please visit our product website.

Why turbine-loader

Testing extension library modules is typically most easily done using a JavaScript testrunner like Karma and a module bundler like Webpack. Using this stack, extension developers can write tests which access library modules using the commonjs require() function, interact with the library module's exports, and run assertions.

As described in the extension development guide, extension library modules are able to require() and consume core modules provided by Turbine. While testing extension library modules, however, require() statements which try to access Turbine core modules would typically fail because the extension library modules are not being run within the context of Turbine. This would typically require the extension developer to use a utility like inject-loader to mock all Turbine core modules being used.

To help reduce this need and simplify testing, turbine-loader provides extension library modules under test with core modules from Turbine. Core modules can still be mocked using a utility like inject-loader as deemed necessary.

How to use turbine-loader

Turbine-loader will only work with Webpack.

First, install turbine-loader as a devDependency within your project:

npm install --save-dev @adobe/reactor-turbine-loader

Second, in the Webpack configuration you are using for running tests, module.postLoaders should be set as follows:

    module: {
        postLoaders: [
                test: /^(?!.*__tests__.*$).*\/src\/lib\/.*$/,
                loader: '@adobe/reactor-turbine-loader'

The value of test must be a regular expression that matches any library module files under test. Be sure that the regular expression only matches library module files under test.

With the configuration in place, Turbine core modules will be injected into these library module files whenever the library module files are required by test files.