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

test.cb does not timeout #1126

Closed
gajus opened this issue Nov 22, 2016 · 4 comments
Closed

test.cb does not timeout #1126

gajus opened this issue Nov 22, 2016 · 4 comments

Comments

@gajus
Copy link

gajus commented Nov 22, 2016

Description

I am using test.cb callback to define an asynchronous test. My test is failing (the expected callback is not called).

Current behaviour

This leaves the entire test suite hanging indefinitely.

Expected behaviour

Expect the test to fail after some X time.

Test Source

test.cb.only('togglePushdown', (t) => {
  console.log('A 0');

  const div = document.createElement('div');

  console.log('A 1');

  div.id = 'pushdown';

  document.body.appendChild(div);

  console.log('A 2');

  const origAnimate = minidom.animate;

  minidom.animate = (...args) => {
    console.log('A 5');

    t.deepEqual(args[1], {
      height: 250
    });

    minidom.animate = origAnimate;

    t.end();
  };

  console.log('A 3');

  AdsManager.togglePushdown();

  console.log('A 4');
});

This produces:

A 0
A 1
A 2
A 3
A 4

Error Message & Stack Trace

None. The test is just hanging.

Config

Copy the relevant section from package.json:

{
  "ava": {
    "require": [
      "babel-register"
    ],
    "babel": "inherit"
  }
}

Command-Line Arguments

Copy your npm build scripts or the ava command used:

ava --verbose --serial --fail-fast --watch ./test/AdsManager.js

Environment

Tell us which operating system you are using, as well as which versions of Node.js, npm, and AVA. Run the following to get it quickly:

$ node -e "var os=require('os');console.log('Node.js ' + process.version + '\n' + os.platform() + ' ' + os.release())"
$ ava --version
$ npm --version
Node.js v7.1.0
darwin 16.1.0
0.17.0
4.0.2

Side note

It would be a useful addition if the DEBUG=* logged which tests it is entering/ leaving to help debug issues such as this one. Now if the test is set to only I am not getting any output unless there is a console.log in the script itself.

$ DEBUG=* ava --verbose --serial --fail-fast --watch ./test/AdsManager.js
ava ipc stats:
{ testCount: 1, hasExclusive: true, file: 'test/AdsManager.js' } +0ms
A 0
A 1
A 2
A 3
A 4
@sindresorhus
Copy link
Member

You need to use the --timeout CLI flag.

@gajus
Copy link
Author

gajus commented Nov 22, 2016

Right. I apologize. I was under impression that there is a default global timeout.

@gajus gajus closed this as completed Nov 22, 2016
@sindresorhus
Copy link
Member

@gajus We considered having a global default, but we realized there's no good default that works for everyone. Instead, we plan to show when we think a test is hanging: #583 (Help welcome btw)

@QuotableWater7
Copy link

@sindresorhus I'd be happy to help look into a solution for #583. To speed along the process, do you know which file(s) I should be taking a look at?

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

3 participants