does-this-module-install
v1.0.1
Published
A starter package for typescript projects
Downloads
4
Maintainers
Readme
does-this-module-install
npm enables creation of small modules to compose larger systems. One problem that surfaces is that smaller modules have to be tested for deployment.
A common cause of error is when a dependency is listed as a dev-dependency. This causes needless frustration - in ensuring all will work.
This module, provides a unit installation test as a function.
The function is independent of test framework. It throws on error
when installing it's root-parent module. Root parent is defined as
the first subdirectory containing node_modules
.
This module, provides a unit installation test, that tests an npm module can be self installed in production mode.
Installation
npm install does-this-module-install -D
or
yarn install doed-this-module-install --save-dev
Usage
runInstallTest
is a simple function that detects the current parent-root module,
uses it's relative path to install the module into a temp directory.
The function is independent of test framework and returns a success message or throws an error.
Use shown below is tied to mocha
, should be easy enough to modify as needed.
// somewhere in your tests
import { runInstallTest } from 'does-this-module-install
// demonstrated with mocha, but should be adaptable to
// any test framework of your choice
describe(`regular module tests`, () => {
it(`install test`, async () => {
expect(await runInstallTest()).to.match(/success! installing .*/);
});
});
Code of conduct
Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.
License
Apache-2.0
Support
Bugs, PRs, comments, suggestions welcomed!