Definitelytyped: Mocha retries compiles but considered not a function at runtime

Created on 19 Jan 2017  路  1Comment  路  Source: DefinitelyTyped/DefinitelyTyped

  • [X] I tried using the latest mocha/index.d.ts file in this repo and had problems.
  • [X] I tried using the latest stable version of tsc. https://www.npmjs.com/package/typescript
  • [X] I have a question that is inappropriate for StackOverflow. (Please ask any appropriate questions there).
  • [X] I want to talk about mocha/index.d.ts.

    • The authors of that type definition are cc/ @kazimanzurrashid @otiai10 @jt000 @enlight

I'm attempting to use the retries callback for a test. The file compiles with no problem, but on runtime, the test fails and gives the error this.retries is not a function

Here's an example of my implementation

describe('suite name'), () => {

   it('test declaration', () => {
      this.retries(3)
   }

}

Another note is that when I use this, I get no intellisense for that object. This is true for tests and suites.

Thanks and let me know if I can do anything else.

Most helpful comment

If you want to use Mocha features via this you need to use unbound functions not arrow functions, as documented: https://mochajs.org/#arrow-functions

>All comments

If you want to use Mocha features via this you need to use unbound functions not arrow functions, as documented: https://mochajs.org/#arrow-functions

Was this page helpful?
0 / 5 - 0 ratings

Related issues

variousauthors picture variousauthors  路  3Comments

fasatrix picture fasatrix  路  3Comments

lilling picture lilling  路  3Comments

jgoz picture jgoz  路  3Comments

Loghorn picture Loghorn  路  3Comments