【发布时间】:2018-05-30 04:19:52
【问题描述】:
我在大多数中遇到超时错误,但不是所有时间我都运行zapier test,无论我是否添加--debug,这是我的代码:
require('should');
const zapier = require('zapier-platform-core');
// Use this to make test calls into your app:
const App = require('../index');
const appTester = zapier.createAppTester(App);
describe('Zapier - ON24 CLI Auth App', () => {
it('should have Access Tokens pass the authentication from ON24 APIs', (done) => {
const bundle = {
authData:{
accessTokenKey: 'abc',
accessTokenSecret: 'def',
client_id: '123'
}
};
appTester(App.authentication.test, bundle)
.then((response) => {
response.status.should.eql(200);
done();
})
.catch(done);
});
});
错误:
错误:超过 2000 毫秒的超时。对于异步测试和钩子,确保 “完成()”被调用;如果返回一个 Promise,请确保它解析
尝试在const bundle 上方添加this.timeout(5000);,但这表示timeout 不是函数。
更新 - 测试模块:
const testAuth = (z, bundle) => {
return z.request({
url: `https://wccqa.on24.com/wcc/api/v2/client/${bundle.authData.client_id}/languages`
}).then((response) => {
if(response.status === 401){
throw new Error('The API Keys provided are invalid');
}
return response;
});
};
module.exports = {
type: 'custom',
fields: [
{
key: 'accessTokenKey', label: 'Access Token Key', required: true, type: 'string'
},
{
key: 'accessTokenSecret', label: 'Access Token Secret', required: true, type: 'string'
},
{
key: 'client_id', label: 'Client Id', required: true, type: 'string'
}
],
test: testAuth,
connectionLabel: 'testAuth connectionLabel'
};
【问题讨论】:
-
我从来没有使用过这个,但是看看文档,
appTester(...)的参数可能有问题。你的App.authentication.test文件/方法是什么样的? -
看起来应该可以了。当测试失败时,请求是否也会失败?您可以通过将控制台日志添加到 catch 函数中来进行检查(也可以从成功中记录下来,这样您就可以看到发生了什么)
标签: node.js zapier-cli