Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ndelangen/jasmine-before-all
Adds a done-friendly beforeAll global function to Jasmine
https://github.com/ndelangen/jasmine-before-all
Last synced: 4 months ago
JSON representation
Adds a done-friendly beforeAll global function to Jasmine
- Host: GitHub
- URL: https://github.com/ndelangen/jasmine-before-all
- Owner: ndelangen
- Fork: true (testdouble/jasmine-before-all)
- Created: 2017-02-08T11:36:37.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-02-24T14:36:23.000Z (almost 8 years ago)
- Last Synced: 2024-09-21T14:33:39.958Z (4 months ago)
- Language: JavaScript
- Size: 11.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
**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](https://travis-ci.org/testdouble/jasmine-before-all.png?branch=master)](https://travis-ci.org/testdouble/jasmine-before-all)
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](https://github.com/juliemr/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](https://github.com/testdouble/jasmine-before-all/releases)**.
# examples
Does what it says on the tin. This would pass, for instance:
```coffeescript
describe 'intentional pollution', ->
foo = 0
beforeAll -> foo += 1context '1', ->
Then -> foo == 1context '2', ->
Then -> foo == 1context '3', ->
Then -> foo == 1afterAll -> 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:
``` coffeescript
describe '(asynchronous) intentional pollution', ->
bar = 3
beforeAll (done) ->
setTimeout ->
bar -= 1
done()
, 100context '1', ->
Then -> bar == 2context '2', ->
Then -> bar == 2context '3', ->
Then -> bar == 2
```