npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ntip

v1.0.0

Published

No Tests In Production. To prevent accidental test execution

Downloads

6

Readme

No Tests In Production

This package is designed to prevent accidentally executing tests in production server.

Introduction

Running tests in production servers is a nightmare. Although test execution in a production server is not intentional, accidents can happen due to human errors, configuration errors. This package is designed to provide a validation against such accidents.

In order to provide the validation, tests should be executed via this package.

How to use

Installing

In order to install use following command.

npm install --save-dev ntip

:hand: Please use --save-dev flag, since this is a package related to dev environments.

( if you use tests suites as mocha, jasmine without --save-dev flag, then install this package without --save-dev flag).

Configuration

(please read the about the npm package json in https://docs.npmjs.com/files/package.json)

NODE_ENV value is mandatory for this package.

In development environment, please set NODE_ENV as development, prior to run tests.

./node_modules/.bin/ntip <test command>

eg:

./node_modules/.bin/ntip ./node_modules/.bin/mocha `find test -name '*.js' -not -path '*test/dummy_test*'`

If the development environment is different than "development", then use following command to execute the package.

export DEV_ENV_TAGS=xyz ./node_modules/.bin/ntip ./node_modules/.bin/mocha `find test -name '*.js' -not -path '*test/dummy_test*'`

In Node Js environment, following command is used to run the.

npm test

A sample configuration for the npm install in package.json is as following.

{
"scripts": {
    "test": "./node_modules/.bin/mocha `find test -name '*.js' -not -path '*test/fixtures*'`"
  }
}

In order to run the test through ntip, change the package.json as follows.

{
"scripts": {
    "test": "./node_modules/.bin/ntip ./node_modules/.bin/mocha `find test -name '*.js' -not -path '*test/dummy_test*'`"
  }
}
Adding more development environment to the NTIP

Set DEV_ENV_TAGS in following format. (please use the "," as the delimiter).

DEV_ENV_TAGS=env1,env2,env3

eg:

DEV_ENV_TAGS=alpha,beta,gamma

If you set as in above example, NODE_ENV with values either "alpha","beta","gamma" will be considered as development environments and will allow to execute the tests.

Important.

  • Never use NODE_ENV in the test command. (refer the example at Features section)
  • Always set the NODE_ENV in development environment.
  • To execute the tests using single line, please use following command.
export DEV_ENV_TAGS=alpha;NODE_ENV=alpha ./node_modules/.bin/ntip ./node_modules/.bin/mocha test/sample.js

Features

  • Default development environment name is set as "*** development ***".

  • Able to identify NODE_ENV names such as "prod", "production", names starts with prod and stop the execution of the tests.

  • Able to detect NODE_ENV overrides which pass through *** test_command ***, and prevent further execution.

    eg: following test command will generate an error when executing.

    ./node_modules/.bin/ntip env NODE_ENV=do_not_pass ./node_modules/.bin/mocha sample.js

Alternative solutions

In order to prevent test execution in the production environment, avoid installing dev dependencies. Using following command, npm will no install dev dependencies.

npm install --production
Stack overflow answer