jasmine-node テストを使用して、いくつかの外部 API テストをテストしようとしています。ただし、テスト スイート全体を実行しても、基本的な接続が機能する場合にのみ意味があります。つまり、これは基本的に、単純な ping テストから他のすべての人にその情報を渡す必要があることを意味します。
それが私が試したことですが、最初のテストに合格してもこれは成功しません:
var canConnect = false;
describe("The API client", function () {
it("can connect server", function (done) {
api.ping(function (err) {
expect(err).toBeNull();
canConnect = true;
done();
})
});
// pointless the run these if the ping didn't work
if (canConnect) describe("connected clients", function () {
it("can use the API", function (done) {
api.someOtherRequest(function(err) {
expect(err).toBeUndefined();
done();
});
})
});
})
助言がありますか?たぶん、これをよりスマートに解決する方法はありますか?
乾杯