Sunday, June 2, 2024
104
rated 0 times [  109] [ 5]  / answers: 1 / hits: 66513  / 12 Years ago, sat, may 12, 2012, 12:00:00

I'm using mocha for javascript unit-testing now.



I have several test files, each file has a before and beforeEach, but they are exactly the same.



How do I provide a global before and beforeEach for all of them (or some of them)?


More From » unit-testing

 Answers
11

Declare a before or beforeEach in a separate file (I use spec_helper.coffee) and require it.



spec_helper.coffee



afterEach (done) ->
async.parallel [
(cb) -> Listing.remove {}, cb
(cb) -> Server.remove {}, cb
], ->
done()


test_something.coffee



require './spec_helper'

[#85631] Thursday, May 10, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jennie

Total Points: 593
Total Questions: 102
Total Answers: 106

Location: Federated States of Micronesia
Member since Fri, Sep 16, 2022
2 Years ago
jennie questions
;