Ped*_*que 10 javascript jasmine jasmine-node frisby.js web-api-testing
我试图使用方法beforeAll和毕竟茉莉,打造一套与测试frisby.js,因为实际上,弗里斯比没有此方法的支持.所以,这就是我要做的事情:
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
Run Code Online (Sandbox Code Playgroud)
如果我将before/afterAll之前的方法更改为before/afterEach,则可以正常工作,但是当我使用before/afterAll时,控制台上会出现此错误:
消息:ReferenceError:未定义beforeAll Stacktrace:ReferenceError:未定义beforeAll
我的项目上安装了jasmine版本2.3.2,所以,我不知道我需要做什么来集成这个方法.
使用 jasmine 库而不是 jasmine-node 库。第二个不支持 beforeAll 和 afterAll 方法。
1- npm install -g 茉莉花
2-茉莉花初始化
3-在spec文件夹中编写测试:
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);
});
});
Run Code Online (Sandbox Code Playgroud)
4-运行测试 --> 茉莉花