Node.js 测试时出现超时错误

Node.js 测试时出现超时错误,node.js,zapier-cli,Node.js,Zapier Cli,我在大多数中都出现超时错误,但并非每次运行zapier测试时都会出现超时错误,无论是否添加--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

我在大多数中都出现超时错误,但并非每次运行
zapier测试
时都会出现超时错误,无论是否添加
--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毫秒的超时时间。对于异步测试和挂钩,请确保 调用“done()”;如果返回承诺,请确保它已解决

尝试添加
此.timeout(5000)高于
const bundle
,但这表示
timeout
不是一个函数

更新-测试模块:
我确实深受这个错误之苦。该错误是由测试框架造成的,测试框架通常不会等待超过
2秒。无论您在测试中做什么,如果不使用下面的方法处理,就会发生超时。在本例中,请在应用程序的package.json中为mocha运行时添加超时(
15秒
)。测试时,请随意设置更高的超时

“脚本”:{
“测试”:“节点模块/mocha/bin/mocha——递归——超时15000”
},


正如其他受访者所说,在最初的代码中添加
z.console.log(msg)
,以查看您的请求发生了什么。

我确实经常遇到这个错误。该错误是由测试框架造成的,测试框架通常不会等待超过
2秒。无论您在测试中做什么,如果不使用下面的方法处理,就会发生超时。在本例中,请在应用程序的package.json中为mocha运行时添加超时(
15秒
)。测试时,请随意设置更高的超时

“脚本”:{
“测试”:“节点模块/mocha/bin/mocha——递归——超时15000”
},


正如其他受访者所说,在代码中添加大量
z.console.log(msg)
,以查看您的请求发生了什么。

对我有效的是使用附加参数运行测试

zapier测试-t 15000


CLI版本是10.0.1

对我有效的是使用附加参数运行测试

zapier测试-t 15000


CLI版本是10.0.1

我从未使用过这个,但是查看文档,
appTester(…)
的参数可能有问题。你的
App.authentication.test
文件/方法是什么样子的?看起来应该可以用。当测试失败时,请求是否也会失败?您可以通过将come控制台日志添加到catch函数中进行检查(也可以从success中进行日志记录,这样您就可以看到问题所在了)。我从未使用过此功能,但查看文档,
appTester(…)
的参数可能有问题。你的
App.authentication.test
文件/方法是什么样子的?看起来应该可以用。当测试失败时,请求是否也会失败?您可以通过在catch函数中添加come控制台日志(也可以从success中记录日志,这样您就可以看到发生了什么)来检查在package.json中添加timeout是否对我有效。谢谢。在package.json中添加超时对我很有效。谢谢
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'
};