tape-testing / tape

tap-producing test harness for node and browsers
MIT License
5.77k stars 307 forks source link

Upgrade to TAP 14 - support for subtests, maybe indentation? #588

Open tristanhoy opened 1 year ago

tristanhoy commented 1 year ago

TAP 14 spec allows for identifying a test as a "subtest"

 TAP version 14
 1..2

 # Subtest: foo.tap
     1..2
     ok 1
     ok 2 - this passed
 ok 1 - foo.tap

 # Subtest: bar.tap
     ok 1 - object should be a Bar
     not ok 2 - object.isBar should return true
       ---
       found: false
       wanted: true
       at:
         file: test/bar.ts
         line: 43
         column: 8
       ...
     ok 3 - object can bar bears # TODO
     1..3
 not ok 2 - bar.tap
   ---
   fail: 1
   todo: 1
   ...

Is migrating to TAP 14 on the roadmap?

This would allow beautifiers to correctly indent subtests as TAP 13 has no mechanism for indicating the "level" of a test (everything is just flat comments).

ljharb commented 1 year ago

Yes, that sounds great. I have no idea how to go about doing that tho :-)

what would be ideal is an env var that sets the TAP version (explicit but unsupported versions should error), that defaults to 13 - then in a future semver-major we could change the default to 14.