Giter VIP home page Giter VIP logo

meteor-mocha-web's Introduction

meteor-mocha-web

meteor-mocha-web allows you to easily and safely run mocha tests within the Meteor framework. This means you can write tests that use and examine Meteor collections.

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

describe "Leaderboard", ->
  describe "givePoints", ->
    it "gives 5 points to the user", ->
      #create a player
      playerId = Players.insert {name: "TestUser1", score: 5}
      Session.set "selected_player", playerId
      givePoints()
      player = Players.findOne(playerId)
      chai.assert.equal 10, player.score
      Players.remove {name: "TestUser1"}

You're free to write your tests in JavaScript or CoffeeScript. The chai assertion library is included in this package, but you're free to use a different assertion library.

Tests are only included when METEOR_MOCHA_TEST_DIRS is defined, so they will only exist on environments you specify.

Setup

  1. Install Meteorite if you haven't already npm install -g meteorite
  2. Add the smart package to your project. mrt add mocha-web
  3. Add {{> mochaTestReport}} to the template where you'd like to see your test results.
  4. When running mrt, specify where your tests live by setting METEOR_MOCHA_TEST_DIRS:
$ METEOR_MOCHA_TEST_DIRS="path/to/project/tests:other/path/to/tests" mrt
  1. Customize mocha options by setting Meteor.public.mocha_setup_args (example below)
{
  "public": {
    "mocha_setup_args": {
      "ui": "tdd",
      "check-leaks": false,
      "globals": ["script*"]
    }
  }
}

Optional Setup

Setting up PhantomJS/Mocha

  npm install -g phantomjs
  npm install -g mocha-phantomjs
  mocha-phantomjs http://localhost:3000

Questions?

This package is in its early stages, so please feel free to ask questions, raise issues, or submit pull requests.

meteor-mocha-web's People

Contributors

jagill avatar mad-eye avatar philcockfield avatar pipedreambomb avatar rissem avatar rossettistone avatar twlcek avatar yevgenko avatar

Watchers

 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.