Skip to content

Latest commit

 

History

History
62 lines (48 loc) · 1.21 KB

README.md

File metadata and controls

62 lines (48 loc) · 1.21 KB

Jest Lights

A jest reporter that turns on and off traffic lights based on test results

Install

npm install --save-dev @vehikl/jest-lights
# OR
yarn add --dev @vehikl/jest-lights

Configure Jest

You'll need to add this reporter to your jest configuration, which may be in package.json#jest, or more recent versions are in jest.config.js.

If you have your jest config in package.json:

{
  // ...
  "jest": {
    // ...
    "reporters": [
      "default",
      "...other-reporters?",
      "@vehikl/jest-lights"
    ]
  }
}

And jest.config.js:

module.exports = {
  reporters: [
    "default",
    "...other-reporters?",
    "@vehikl/jest-lights"
  ]
}

Run Tests

You'll need to set the LIGHTS_API_HOST environment variable. By default, it points to localhost:8080, but this will likely be wrong. If not configured, or configured incorrectly, you will see a warning message with appropriate instructions.

For best results, set the environment variable in your package.json#scripts#test script:

{
  "scripts": {
    // ...
    "test": "LIGHTS_API_HOST=192.168.0.xxx:8080 jest"
  }
}

If all goes to plan, the traffic lights will change as you run your tests.