installed-package

1.0.2 • Public • Published

installed-package

Note: For the installs to actually work, you'll need a version of node that supports execFileSync (node >=4). The module will gracefully degrade for earlier node versions.

A helper library that lets you run your tests against an installed version of your package. This helps catch publish-related problems like:

  • Files that aren't included in the npm package.
  • Imports of devDependencies in the files shipped to npm.

During normal test runs it will just require the files from the project directory. Only when you run the tests with CI=true will it do a fresh install of the package to a temporary directory and redirect imports there.

Usage

Install

npm install --save-dev installed-package

Test Setup

If this is how your tests are currently importing your package:

var mainExport = require('..');
var secondaryEntryPoint = require('../secondary');

// Test code that uses `mainExport`/`secondaryEntryPoint`...

Replace it with the following:

var installed = require('installed-package')();

var mainExport = installed();
var secondaryEntryPoint = installed('secondary');

// Test code that uses `mainExport`/`secondaryEntryPoint`...

API

The default export of this module is installPackage.

installPackage(packageRoot = process.cwd(), doInstall = process.env.CI)

Installs the npm package located at packageRoot into a temporary directory. Returns a function that will require a module relative to the installed package. If the function is called without an argument, the main entry point of the package will be required.

Readme

Keywords

none

Package Sidebar

Install

npm i installed-package

Weekly Downloads

1

Version

1.0.2

License

BSD-3-Clause

Last publish

Collaborators

  • groupon