Skip to content

Test hangs or times out on some TypeScript compilation errors. #3031

Closed
@paulgb

Description

@paulgb

When I run this test:

import test from 'ava'

test('foobar', async (t) => {
    const foo_1 = foo()
    const foo_2 = foo()
    const foo_3 = foo()
    const foo_4 = foo()
    const foo_5 = foo()
    const foo_6 = foo()
    const foo_7 = foo()
})

Instead of reporting a compilation error, I get this:

  ✖ Timed out while running tests

If I remove one of the declarations, I get the following, as expected:

  Uncaught exception in src/test-spawn.ts

  src/test-spawn.ts(4,19): error TS2304: Cannot find name 'foo'.
  src/test-spawn.ts(5,19): error TS2304: Cannot find name 'foo'.
  src/test-spawn.ts(6,19): error TS2304: Cannot find name 'foo'.
  src/test-spawn.ts(7,19): error TS2304: Cannot find name 'foo'.
  src/test-spawn.ts(8,19): error TS2304: Cannot find name 'foo'.
  src/test-spawn.ts(9,19): error TS2304: Cannot find name 'foo'.
  

  ✖ src/test-spawn.ts exited with a non-zero exit code: 1
  ─

  1 uncaught exception

It seems there's some threshold (maybe the amount of tsc output?) that's causing ava to time out rather than report the error.

This occurs when using the ts-node/register TypeScript approach (https://github.com/avajs/ava/blob/main/docs/recipes/typescript.md#for-packages-without-type-module).

I've created a minimal reproducible example here: https://github.com/paulgb/ava-timeout-issue-repro

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions