jest-verify-node-version

1.0.3 • Public • Published

jest-verify-node-version

Within Jest Setup, verify node version

This module uses process.version to retrieve the current version of node.

Usage

const { check } = require('json-verify-node-version');
 
// use CWD package.json
check(); // = true
 
// provide package.json-like object
check({ engines: { node: '>= 10' } }); // = true

Example with Jest

// jest.config.js
{
    //...
    "globalSetup": "<rootDir>/global.setup.js"
    //...
}
 
// global.setup.js
const { check } = require('jest-verify-node-version');
 
module.exports = async () => {
    check();
};

If the node version doesn't satisfy the engine node version range and doNotThrow is not true, then the check function will throw an error. For example:

$ npm test
 
> example-module@1.0.0 test /Users/julian/dev/example-module
> jest
 
Error: node version v10.16.3, does not satisfy engine requirement of >=12.13.0

Package Sidebar

Install

npm i jest-verify-node-version

Weekly Downloads

79

Version

1.0.3

License

MIT

Unpacked Size

16.6 kB

Total Files

9

Last publish

Collaborators

  • mrlannigan