jasmine-before-all
Adds a done-friendly beforeAll setup to jasmine
Last updated 3 years ago by searls .
Apache License 2.0 · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install jasmine-before-all 
SYNC missed versions from official npm registry.

WARNING: This plugin relies on internal Jasmine code that was refactored or removed in Jasmine 2.0. Currently compatible with Jasmine 1.x only

jasmine-before-all

Build Status

jasmine-before-all is a standalone plugin that you can load after jasmine that adds global beforeAll and afterAll functions that call beforeEach and afterEach, respectively, at most one time per callback definition.

Importantly, they play nicely with done mechanisms like those found in minijasminenode.

Using beforeAll/afterAll is typically a bad idea for unit tests, but if you're using Jasmine for integration tests, it'll probably come in handy as soon as your setup becomes expensive.

Download the latest version here.

examples

Does what it says on the tin. This would pass, for instance:

describe 'intentional pollution', ->
  foo = 0
  beforeAll -> foo += 1

  context '1', ->
    Then -> foo == 1

  context '2', ->
    Then -> foo == 1

  context '3', ->
    Then -> foo == 1

  afterAll -> foo++; expect(foo).toEqual(2)

And if your test runner includes a "done" callback (or you've included one as a helper), this should also work:

describe '(asynchronous) intentional pollution', ->
  bar = 3
  beforeAll (done) ->
    setTimeout ->
      bar -= 1
      done()
    , 100

  context '1', ->
    Then -> bar == 2

  context '2', ->
    Then -> bar == 2

  context '3', ->
    Then -> bar == 2

Current Tags

  • 0.1.2                                ...           latest (3 years ago)

5 Versions

  • 0.1.2                                ...           3 years ago
  • 0.1.1                                ...           3 years ago
  • 0.1.0                                ...           6 years ago
  • 0.0.2                                ...           7 years ago
  • 0.0.1                                ...           7 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 1
Last Month 22
Dependencies (0)
None
Dev Dependencies (5)

Copyright 2014 - 2016 © taobao.org |