emberjs / ember-qunit

QUnit test helpers for Ember
Other
259 stars 154 forks source link

Test timed out. #327

Open devdemi opened 6 years ago

devdemi commented 6 years ago

Hi, I've started with acceptance tests in Ember.js and wrote simple test

test('visit teacher', async function(assert) {
        await visit('/teacher/6');
        assert.ok(find('h1.name'), 'Ричард_test');
});

And when I start test I get error: Test took longer than 60000ms; test timed out.@ 60099 ms This route requests data from server. But when I try to create test of visiting route without data requests then test runs well. I use Ember 3.1 and ember-qunit 3.4.0

nlfurniss commented 6 years ago

Are you mocking the response? If not, the promise created in your route to fetch data will not resolve, the test can't move on, and it will time out

chris-aeviator commented 5 years ago

So do you have any idea on how to modify the timeout - my ember-qunit also runns into this when using the await pauseTest() function, which kind of destroys your debugging session (in the browser) after that timeout.

It would be useful to disable or set the timeout to a very high value via the commandline to adjust.

One (in my view) valid use-case of ember-quit is also to help as a interaction script when doing tdd - I'd like to test something which is several steps away (click button, fill form, …) from my route entry, which are steps I do not want to always redo manually after a file change.

BobrImperator commented 5 years ago

@chris-aeviator I usually run a specific test in devmode, then the pauseTest won't timeout.

also https://api.qunitjs.com/config/QUnit.config

Mifrill commented 4 years ago

@devdemi check the redefine of QUnit.config.testTimeout value in config files. most luckely here: tests/test-helper.js it looks like it redefined to 60000 in your case to force the fail on unexpected errors.

so, to resolve this issue we can temporarily change this value into default: undefined:

QUnit.config.testTimeout = undefined;

QUnit.config.testTimeout (number) | default: undefined source: https://api.qunitjs.com/config/QUnit.config

Mifrill commented 4 years ago

@BobrImperator it seems like you using the updated version of ember-qunit-cli that why it works for you in dev mode: https://github.com/ember-cli/ember-cli-qunit/pull/120/files

@devdemi so, before upgrade we can you the same approach here:

QUnit.config.testTimeout = QUnit.urlParams.devmode ? undefined : 60000;
Mifrill commented 4 years ago

ah :smile: sorry, the main goal of this issue was completely different :smiley:

I was surfed and looked at the last comments only, so decided that the issue is that the test crashes with timeout error when pauseTest is used for debugging

so this response is totally correct:

Are you mocking the response? If not, the promise created in your route to fetch data will not resolve, the test can't move on, and it will time out

Thanks to @nlfurniss

This route requests data from server. But when I try to create test of visiting route without data requests then test runs well.

check the mock of get requests in your mirage server config, you probably have mock like: this.get('/teacher'); but not like: this.get('/teacher/:id');

so, just add it, btw, it probably should be teacherS not teacher to produce the index request, and /teachers/:id for show request

NetFreak26 commented 2 years ago

Are you mocking the response? If not, the promise created in your route to fetch data will not resolve, the test can't move on, and it will time out

Hey, can u also tell where we can mock the response like in which directory or file?