lokimidgard
lokimidgard

Reputation: 1119

Mocha TypeScript Error "this.timeout is not a function" without Arrow Function

I try to create a test with mocha that has a timeout. However, I got an error TypeError: this.timeout is not a function.

This seems to be an easy to solve error. But when I searched for this error I always find the solution: Don't use arrow functions. Unfortunatly that does not seem to be the Problem here.


My simplified Test:

import 'mocha';
import 'ts-mockito';

describe('Function', function () {

    it('function', function (done: MochaDone) {
        this.timeout(5);
    });
});

Upvotes: 2

Views: 2608

Answers (1)

lokimidgard
lokimidgard

Reputation: 1119

I used another approach using anotaitions

@suite(timeout(3000), slow(1000))
export class MainTest {

    @test async Test1() {
        ...
    }
}

As discribed in the repo mocha-ts.

Upvotes: 4

Related Questions