小编Dan*_*tta的帖子

茉莉花与助手

我是 Jasmine 测试的新手,我需要测试 Nodejs Express 应用程序。我没有找到任何有关在所有测试之前调用的茉莉花助手的文档。

只是尝试我发现添加

beforeAll(async()=>{
   ...
});
afterAll(async()=>{
   ...
});
Run Code Online (Sandbox Code Playgroud)

在我的 /spec/helpers/myhelper.js 中,这些函数在所有代码之后和之前执行,但我没有在帮助程序中找到有关此行为的文档。这是标准行为吗?

是否可以在 myhelper.js 中创建我的辅助函数并在测试期间调用该函数?如何?

我的实际 /spec/helpers/myhelper.js 是:

let server = require("../../app");
console.log('server started before tests....');

function testMethod(){
    console.log("test helper called");
}
Run Code Online (Sandbox Code Playgroud)

如何从我的测试中调用我的测试辅助方法?

我使用的是茉莉花版本3.2.1

javascript node.js jasmine

5
推荐指数
1
解决办法
6834
查看次数

Check if at least one object is not zero

This function need to check that a=b=c=0 or only one is <>0

there is a best way to do this check?

void (int p, int a, int s) {
    if ((p != 0 && a != 0) 
        || (p != 0 && s != 0)
        || (a != 0 && s != 0)
        || (a != 0 && s != 0 && p != 0)) throw new Exception("Error please set A or P or S");

}
Run Code Online (Sandbox Code Playgroud)

c#

2
推荐指数
1
解决办法
210
查看次数

标签 统计

c# ×1

jasmine ×1

javascript ×1

node.js ×1