Why is the native NodeJS test runner TAP output truncated?

264 Views Asked by At

NodeJS now comes with a builtin native test runner enabled by the --test flag.

node --test

Which sends TAP version 13 output to stdout.

However, it is incomplete and contains ... in multiple places to signify that the output is truncated.

not ok 1 - misc
   ---
   duration_ms: 5.883684
   failureType: 'subtestsFailed'
   error: '1 subtest failed'
   code: 'ERR_TEST_FAILURE'
   ...

I thought that it might be due to it being output to the terminal, so I tried redirecting it to a file.

node --test > temp.tap

Which produced the exact same result.

I also tried to use the run function from the node:test module, and apart from having to specify all of my test files manually, because it wasn't able to locate them automatically like the console command does, it sends the same exact truncated output to stdout.

What is the cause of this and is there any solution I might try?

1

There are 1 best solutions below

3
IronGeek On

The output is actually, not truncated.

According to the TAP specification, the three dots ... is actually part of YAML blocks/ YAML diagnostics:

TAP 13

YAML blocks

If the test line is immediately followed by an indented block beginning with /^\s+---/ and ending with /^\s+.../ that block will be interpreted as an inline YAML document. The YAML encodes a data structure that provides more detailed information about the preceding test...

TAP 14

YAML Diagnostics

If a Test Point is followed by a 2-space indented block beginning with the line — and ending with the line …, separated from the Test Point only by comments or whitespace, then the block of lines between these markers will be interpreted as an inline YAML Diagnostic document according to version 1.2 of the YAML specification...