test-selector

1.0.1 • Public • Published

Test Selector · npm version Build Status Coverage Status

A helper CLI tool to make it easier to run just the tests you want to run.

test-selector will look through your package.json file's scripts object and pick out the ones following the test:testName scheme. It will then ask you which one of those tests you want to run! Or, if you already know the test you want to run, you can include its name in the command.

Installation

$ npm install -g test-selector --save

Basic usage

$ tst

tst

Run a specific test

Already know which test you want to run? Cool! The following command is the same as npm run test:api.

$ tst api

Output:

[tst] Running the test suite: api

Setting up your tests

tst assumes that your package.json file's scripts object is formatted like this:

{
  "scripts": {
    "test": "test for things",
    "test:api": "test just the api",
    "test:compiler": "test just the compiler"
  }
}

Available options

Option Default Description
-p, --prefix 'test' A string that comes before all tests.
-s, --separator ':' Character that separates the prefix from the test name.

You can use these options like this:

$ tst --prefix unit-test --separator -

This will suggest any scripts that look like unit-test-TESTNAME.

Configuration in your package.json file

You may also add a "tst" object to your project's package.json file.

{
  "scripts": {
    "test": "test for things",
    "unit-test-api": "test just the api",
  },
  "tst": {
    "prefix": "unit-test",
    "separator": "-"
  }
}

Writing your tests

For each testing library, there's a different way to separate your tests if you don't want to run them all. I'm not an expert in every testing library, so here are a few resources you can look at:

Contributing

I'd love your contributions! Feel free to open up an issue or submit a PR. Thanks 💖

Changelog

  • 1.0.0 - Initial release
  • 1.0.1 - Enable settings in package.json

Package Sidebar

Install

npm i test-selector

Weekly Downloads

1

Version

1.0.1

License

MIT

Last publish

Collaborators

  • jasonetco