Thanks to visit codestin.com
Credit goes to github.com

Skip to content

t.log() does not output anything if an async test fails due to time out #3122

@kevo1ution

Description

@kevo1ution

First, thanks for maintaining such a great tool. So far it has addressed most of our javascript unit and integration test running needs.

What you're trying to do
I would like to see important test debug logs even if it times out.

What happened
Simple async test that will timeout because the promise resolves after 20 seconds. The test has a simple t.log() invocation.

import test from 'ava';

test('example where logs are not provided by ava when test time out', async (t) => {
  t.log({ message: 'Very important debug statement, that developer would love to see in output after test run' });

  await new Promise((res) => {
    console.log('start promise that resolves after timeout...');
    setTimeout(res, 20000);
  });
});

Simple test output (note ava is run with timeout=1s configured):

 $ npx ava --timeout=1s --verbose

start promise that resolves after timeout...
  
  ✖ Timed out while running tests

  1 tests were pending in test/example.js

  ◌ example where logs are not provided by ava when test time out

  ─

  1 test remained pending after a timeout

What you expected to happen
I expected the output to contain the log: Very important debug statement, that developer would love to see in output after test run.
Being able to see this log will be very helpful in determining why the test timed out.

Environment
package.json

{
  "name": "ava-logging-timeout-bug",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "type": "module",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "ava": "^4.3.3"
  }
}
$ node -v 
v16.16.0
$ npx ava --version
4.3.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions