【发布时间】:2016-05-25 04:11:45
【问题描述】:
我在 Node 中有一条获取身份验证密钥的路由。我想在我的所有 jasmine 测试中使用此身份验证密钥作为 URL 请求中的参数。我希望 SetUp 函数运行,设置一个全局变量,然后允许我在所有其余的测试用例中使用这个变量。
设置功能
var global_key = request({
uri : 'http://localhost:3000/grabToken',
method : 'GET'
},
function (err, body, res) {
if (err) { console.log(err);}
else {
return body['auth_key'];
}
});
测试套件
function testCases() {
describe(TEST_SUITE, function() {
describe("GET /retrieveSecret/VALID_UUID", function() {
it('Requests the secret - Successful response', function(done) {
// ...
}
}
}
}
【问题讨论】:
标签: javascript node.js jasmine