Giter VIP home page Giter VIP logo

meteor-mocha-web's Introduction

velocity-mocha

meteor add mike:mocha

This meteor package allows you to easily and safely run mocha tests within Meteor. It is built upon the Velocity testing framework.

Here's an example using CoffeeScript (or check out the full Meteor project w/ tests)

MochaWeb?.testOnly ->
  describe "Leaderboard", ->
    describe "givePoints", ->
      it "gives 5 points to the user", ->
        #create a player
        playerId = Players.insert {name: "TestUser1", score: 5}
        Session.set "selectedPlayer", playerId
        # wait 100ms for button to appear, then continue
        setTimeout (->
          $('button.inc').click()
          player = Players.findOne(playerId)
          chai.assert.equal player.score, 10
          Players.remove playerId
          done()
        ), 100

Setting Up

The above test will work with the leaderboard example shipped with Meteor 1.0.

  1. Create the app with meteor create --example leaderboard
  2. Change the current working directory to leaderboard
  3. Start the app by running meteor
  4. Add CoffeeScript support with meteor add coffeescript
  5. Create the directory tests/mocha/client
  6. Save the above test code in a file called tests/mocha/client/leaderboard.coffee
  7. Navigate to the app (http://localhost:3000/ by default) and click the Velocity icon in the upper right to see test results

You're free to write your tests in any Meteor supported extension. The chai assertion library is included within this package for your convenience.

(requires Meteor 0.9+)

Testing a local installation of mocha

  1. Clone this repository somewhere git clone https://github.com/mad-eye/meteor-mocha-web
  2. Create a packages directory in the root of your app if it doesn't already exist cd YOUR_APP && mkdir packages
  3. Create a symlink to the repository you cloned cd YOUR_APP/packages && ln -s /PATH/TO/meteor-mocha-web mike:mocha
  4. Add the package to the application : meteor add mike:mocha
  5. Run your app

Running tests in Continuous Integration

Use the commmand:

meteor --test --release velocity:[email protected]_2

The release velocity:[email protected]_2 contains a fix for running the client integration tests.

Using mike:mocha-package

See the README for this fork https://github.com/mad-eye/meteor-mocha-web/tree/packageTest

Deubgging serverside tests

VELOCITY_DEBUG_MIRROR=mocha meteor

meteor-mocha-web's People

Contributors

abernix avatar alanning avatar creepgin avatar hexsprite avatar jagill avatar jfols avatar jimmack1963 avatar johnthepink avatar kidsil avatar mad-eye avatar meonkeys avatar philcockfield avatar pipedreambomb avatar rissem avatar rossettistone avatar samhatoum avatar sanjosolutions avatar serut avatar skv-headless avatar taromero avatar twlcek avatar udnaan avatar yevgenko avatar

Stargazers

 avatar

Watchers

 avatar  avatar

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.