Skip to content

Instantly share code, notes, and snippets.

@bradmontgomery
Last active December 17, 2015 20:19
Show Gist options
  • Save bradmontgomery/5667229 to your computer and use it in GitHub Desktop.
Save bradmontgomery/5667229 to your computer and use it in GitHub Desktop.
Some notes from @jakerella's JS Testing talk at MemphisPHP

JS Testing

About:

The Tools

Get Started

  • install node (e.g. apt-get install node, brew install node)
  • install grunt (e.g. npm install -g grunt-cli)
  • grab qunit fromt he website
  • start a project; e.g. (see Jordan's blog post)
quiry/
    src/
        quirky.js       -- a sample app to test
    tests/
        lib/
        index.html      -- html document that qunuit uses
        quinit.tests.js -- the tests!
    Gruntfile.js
    package.json

Trying it out

  • just open the index.html file, and see the output generated by qunit.
  • inspect the listed assertions
  • check out the asyncTest for testing asynchronous stuff
  • testing in the browser is tedious, so...

Use Grunt to run tests

  • package.json is a node package config. note the devDependencies -- requirments for development
  • get your requirements installed: npm install
  • Gruntfile.js is where you configure grunt tasks & watch folders (e.g. automatically run tests when things change)
  • Run grunt to test.
  • Run grunt watch to run the watch task.

See also

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