Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: this.timeout is not a function #56

Closed
willfarrell opened this issue Jul 4, 2017 · 2 comments
Closed

TypeError: this.timeout is not a function #56

willfarrell opened this issue Jul 4, 2017 · 2 comments

Comments

@willfarrell
Copy link

The default timeout for tests is 6 seconds. In case you need to apply a different timeout, that can be done in the test file using using this.timeout(milliseconds) in the define, after, before or it -blocks.

I'm trying the extent the timeout but keep getting TypeError: this.timeout is not a function. Are the docs out of date?

'use strict';

// tests for mapServicePrint
// Generated by serverless-mocha-plugin

const mod = require('../handlers.js');
const mochaPlugin = require('serverless-mocha-plugin');

const lambdaWrapper = mochaPlugin.lambdaWrapper;
const expect = mochaPlugin.chai.expect;
const wrapped = lambdaWrapper.wrap(mod, { handler: 'print' });

describe('mapServicePrint', () => {

  before((done) => {
//  lambdaWrapper.init(liveFunction); // Run the deployed lambda

    done();
  });

  it('should return 200', (done) => {
    this.timeout(30000); // <--- ******
    return wrapped.run({}).then((response) => {
      expect(response.statusCode).to.be.equal(200);
      expect(response).to.not.be.empty;
      done();
    });
  });
});
@mpuittinen
Copy link
Contributor

mpuittinen commented Jul 9, 2017

@willfarrel This seems to be an issue with the arrow function syntax (this is not defined). Please use

  it('should return 200', (done) => {
     ...
  }).timeout(xxxx);

instead. Thanks for the feedback, I updated the README.

@willfarrell
Copy link
Author

Of course, I should of known that. My bad.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants