Coder Social home page Coder Social logo

test-selector's Introduction

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

test-selector's People

Contributors

jasonetco avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

test-selector's Issues

Add support for running multiple tests

Currently, you can do one of three things:

  1. Run tst and pick "All of them."
  2. Run tst and pick the test suite you want to run.
  3. Run tst TEST and run that test suite.

Wouldn't it be great if you could pick two, unrelated test suites and run them in isolation, but sequentially?

Either by way of a checkbox list instead of a single-choice list, or by allowing multiple arguments in the CLI (like tst api compiler).

Leaving this open as a hacktoberfest issue in case anyone wants to tackle it!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.