Giter Club home page Giter Club logo

installed-package's Introduction

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.