before/afterAll() is not defined in jasmine-node
Asked Answered
L

2

11

I'm trying to use the methods beforeAll and afterAll of jasmine, to create a suite of tests with frisby.js, because actually, frisby doesn't have a support for this methods. So, this is what I'm trying to do:

var frisby = require('frisby');
describe("setUp and tearDown", function(){
    beforeAll(function(){
        console.log("test beforeAll");
    });

    afterAll(function(){
        console.log("afterAll");
    });

//FRISBY TESTS
}); //end of describe function

If I change the methods before/afterAll to before/afterEach, is working, but when I'm using before/afterAll this error appears on console:

Message: ReferenceError: beforeAll is not defined Stacktrace: ReferenceError: beforeAll is not defined

I have the jasmine version 2.3.2 installed on my project, so, I don't know what I need to do to integrate this method.

Leaving answered 21/8, 2015 at 13:16 Comment(0)
S
2

Use the jasmine library not the jasmine-node library. The second one does not support beforeAll and afterAll methods.

1- npm install -g jasmine

2- jasmine init

3- write the test in the spec folder:

  describe("A spec using beforeAll and afterAll", function() {
    var foo;

    beforeAll(function() {
     foo = 1;
    });

    afterAll(function() {
     foo = 0;
    });

    it("sets the initial value of foo before specs run", function() {
      expect(foo).toEqual(1);
      foo += 1;
    });

   it("does not reset foo between specs", function() {
     expect(foo).toEqual(2);
   });
});

4- Run the tests --> jasmine

Salinger answered 21/8, 2015 at 15:23 Comment(2)
But the problem is, I need to use the jasmine-node to execute the frisby.js tests, because im doing tests on an api service..Leaving
Why was this answer voted down. @Salinger is right, jasmine-node doesn't support these methods.Swaraj
W
1

The current version of frisby doesnt suport this kind of setup. The community, like myself is eager to this feature like in this issue describes.

The team is working on this feature, but it will come in version 2 of the package that is in the way for more than a year now. More info at this link.

Wild answered 19/7, 2017 at 14:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.