An opinionated (but complete) set of tools for functional testing
Last updated 3 years ago by jpunt .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install green-light 
SYNC missed versions from official npm registry.


There are a lot of ways you can test your project. You can go with unit-testing, integration-testing, end-to-end-testing, or by manually clicking around your site to see everything still works.

My personal favorite is functional testing. Write tests for each functionality of your project, simulate different circumstances which this specific part can run in and make sure everything is still O.K. An example would be:

import { api, browser, expect } from 'green-light';

describe('article title', () => {
  describe('when it has a title', () => {
    it('renders the title', (done) => {
        .andReplace('/title', 'Some title');

        .then((window) => {
          expect(window.$('h1').text()).to.equal('Some title');
        .then(done, done);

  describe('when it has no title', () => {
    it('renders no title', (done) => {
        .andReplace('/title', null);

        .then((window) => {
        .then(done, done);

GreenLight bundles all the tools you'll need to do exactly this. It can be configured and runned with Node.

Getting started

Follow the steps of the getting started guide, check out an example of a setup over here, or take a look at the documentation for each part of GreenLight for more details:


A mocked version of your API, to control what data is returned for certain URL's and usecases. Based on mocked-api.

Read more.


The project you'd like to test, connected to the mocked API.

Read more.


A virtual browser that visits the page that you're testing. Based on jsdom.

Read more.


The actual code you'll be writing to test your project. Based on mocha and chai.

Read more.

Don't use this if

  • You can't (or don't want to) run Node.
  • You want to use Jasmine, Karma, CasperJS, RSpec, PhantomJS, Nightwatch, NodeUnit, Shoulda, Velocity, Protractor, Vows, Mockito, Sinon, Cucumber, ZombieJS, Selenium, JUnit, or whatever. GreenLight works with mocha, chai, jsdom and mocked-api. These tools are great (or good enough) and I believe that support for anything else is not worth the complexity.
  • You don't want to write functional tests. Unit-tests, for example, are awesome in some cases, but you don't need GreenLight for that. If you want to do something else than functional testing, I'd suggest to use plain Mocha instead. This doesn't mean that you can't combine different kinds of testing though! It's not weird to do both unit-testing and functional-testing for the same app (where appropriate).
  • Your project doesn't get its data from an API that you can mock. A large part of functional testing is to simulate different kinds of data and test how your app is responding to that. If you can't do that, GreenLight is probably not a greath fit and you should go with a different kind of setup.

Use this if

  • You can run Node. This doesn't mean that your project has to be written in Node though. In fact, your project can be written in any language, as long as GreenLight can run it with some kind of command. Node is only needed for running the test-suite, mocked API and the virtual browser.
  • Your project gets its data from an API and you can configure it to a mocked version of that.
  • You're ok with mocha, chai, jsdom and mocked-api. Remember what I said about chai? Well actually.. you can use any other assertion-library, but you've got to install and import it yourself.

Current Tags

  • 0.5.1                                ...           latest (3 years ago)

23 Versions

  • 0.5.1                                ...           3 years ago
  • 0.5.0                                ...           3 years ago
  • 0.4.8                                ...           4 years ago
  • 0.4.7                                ...           4 years ago
  • 0.4.6                                ...           4 years ago
  • 0.4.5                                ...           4 years ago
  • 0.4.4                                ...           4 years ago
  • 0.4.3                                ...           4 years ago
  • 0.4.2                                ...           4 years ago
  • 0.4.1                                ...           4 years ago
  • 0.3.1                                ...           4 years ago
  • 0.2.2                                ...           4 years ago
  • 0.2.1                                ...           4 years ago
  • 0.1.9                                ...           4 years ago
  • 0.1.8                                ...           4 years ago
  • 0.1.7                                ...           4 years ago
  • 0.1.6                                ...           4 years ago
  • 0.1.5                                ...           4 years ago
  • 0.1.4                                ...           5 years ago
  • 0.1.3                                ...           5 years ago
  • 0.1.2                                ...           5 years ago
  • 0.0.2                                ...           5 years ago
  • 0.0.1                                ...           5 years ago
Maintainers (1)
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (10)
Dev Dependencies (8)
Dependents (1)

Copyright 2014 - 2016 © |