est*_*con 0 node.js zapier-cli
我在大多数但不是所有的时间都会出现超时错误,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);
});
});
Run Code Online (Sandbox Code Playgroud)
错误:
错误:超出2000ms的超时.对于异步测试和挂钩,确保调用"done()"; 如果返回Promise,请确保它已解决
尝试添加this.timeout(5000);上面,const bundle但这说明这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'
};
Run Code Online (Sandbox Code Playgroud)
小智 6
我确实遭受了这个错误很多.错误是由于测试框架通常不会等待2 seconds.无论您在测试中执行什么操作,如果未使用以下内容处理,则会发生超时.在你的应用程序的package.json中,请15 seconds在此示例中为mocha runtime()添加超时.在测试时,请随意设置更高的超时.
"scripts": {
"test": "node node_modules/mocha/bin/mocha --recursive --timeout 15000"
},
正如其他受访者所说,z.console.log(msg)最初添加到您的代码中以查看您的请求发生了什么.
| 归档时间: |
|
| 查看次数: |
447 次 |
| 最近记录: |