Skip to content

Instantly share code, notes, and snippets.

@philbirnie
Last active June 2, 2016 17:29
Show Gist options
  • Save philbirnie/10cb33c5e488ea70f36e9c988f84ca9d to your computer and use it in GitHub Desktop.
Save philbirnie/10cb33c5e488ea70f36e9c988f84ca9d to your computer and use it in GitHub Desktop.
JS Testing Setup

JS Testing Setup

Testem.json Setup

Start with a testem.json file that includes sinon for stubbing, etc as well as any files that would be utilized in testing.

{
  "framework": "mocha+chai",
  "launch_in_dev": ["Chrome", "phantomjs"],
  "serve_files": [
    "node_modules/sinon/pkg/sinon.js",
    "js/promise-polyfill.js",
    "js/modules/map.js",
    "js/modules/geocode.js",
    "js/modules/geolocation.js",
    "js/tests/**.js"
  ],
  "launchers": {
    "mocha": {
      "command": "mocha js/tests"
    }
  },
  "phantomjs_debug_port": 5050
}

Install requisite dependencies

  • Chai
  • Mocha
  • Sinon
  • Testem

npm install chai mocha sinon testem --save-dev

Start Testing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment