You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Luke Childs 1a2a256ffa 1.0.0 7 years ago
src Use pkg-dir 7 years ago
test Fix test 7 years ago
.gitignore Initial commit 7 years ago
.travis.yml Initial commit 7 years ago
LICENSE Initial commit 7 years ago
README.md Link to AVA 7 years ago
package.json 1.0.0 7 years ago

README.md

requireable

Enables a module to require itself by name in tests

Build Status Coverage Status npm

Mocks the require command to include the current package when the name from the current package.json is required.

Uses process.cwd() to find the current package.json so this is only meant to be used as a dev dependency for testing. This will not work on a published package!

Install

npm install --save-dev requireable

Usage

require('requirable');
// That's it! `require` has now been patched

const myPackage = require('package-name')

AVA Usage

Some tests runners such as AVA can require packages automatically for you. If you're using AVA add the following to your package.json:

"ava": {
  "require": [
    "requireable"
  ]
},

You can now require (or import) your package in your AVA tests.

e.g instead of:

import test from 'ava';
import myPackage from '../';

You can now do:

import test from 'ava';
import myPackage from 'package-name';

License

MIT © Luke Childs