1

I get a timeout error in most but not all the times i run zapier test whether i add --debug or not, here's my code:

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);
  });
});

Error:

Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves

Tried adding this.timeout(5000); above const bundle but this says that timeout is not a function.

Update - test module:

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'
};
Esteban Rincon
  • 2,040
  • 3
  • 27
  • 44
  • I've never used this, but looking at the docs it could be something wrong with the argument to `appTester(...)`. What does your `App.authentication.test` file/method look like? – Phix Dec 15 '17 at 23:31
  • that looks like it should work. when the test fails, does the request also fail? you might check by adding come console logs into the catch function (and log from success too, so you see what's up) – xavdid Dec 15 '17 at 23:32

2 Answers2

6

I did suffer from this error a lot. The error is due the test framework which normally doesn't wait beyond 2 seconds. Whatever you do in the tests, timeout occurs if not handled using something like the following. In your app's package.json, please add a timeout to mocha runtime (15 seconds) in this example. Please feel free to set a higher timeout while you are testing.

"scripts": { "test": "node node_modules/mocha/bin/mocha --recursive --timeout 15000" },

As other respondents said, add z.console.log(msg) to your code a lot initially to see what is happening with your requests.

Prasad
  • 349
  • 2
  • 6
1

What worked for me is running tests with an additional parameter

zapier test -t 15000

The CLI version is 10.0.1

Dmitry Kh
  • 126
  • 2
  • 10