Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Travis CI Fail Jest testing for Timeout reason

The exact error message is :

Timeout - Async callback was not invoked within timeout  
specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.

At first, only Node.js 4 version build was failing.
After adding more test, all Node.js version builds were broken (4, 6, 7, 8).

I use Travis CI for my test and Jest (for a Yeoman generator).

You can check out the job log error message if you want.

Tried:

Set a new timeout value.

let originalTimeout;

describe('generator-cozen-angular:sub-task', () => {
    beforeEach(() => {
        originalTimeout                  = jasmine.DEFAULT_TIMEOUT_INTERVAL;
        jasmine.DEFAULT_TIMEOUT_INTERVAL = 30000;
    });

    afterEach(() => {
        jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
    });

    it('do some stuff');
});

If you have an idea or a solution, you will save my day.
Thanks.

like image 871
C0ZEN Avatar asked Feb 01 '26 04:02

C0ZEN


1 Answers

I just found out the solution by reading the Jest documentation.

Since the errors are only in Travis CI, I assumed that their servers were just slower than my local one.

With that information, running :

jest --runInBand

Fixed my problems.

EDIT 1:

I encountered the problem one more time by addind more tests.
The other solution found is to change the Jest timeout.

jest.setTimeout(10000);

Where 10000 is milliseconds. To add on top of the file just before the describe.

like image 78
C0ZEN Avatar answered Feb 02 '26 21:02

C0ZEN



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!