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

Working with node-tap 14? #23

Open
jsumners opened this issue Jul 26, 2019 · 7 comments
Open

Working with node-tap 14? #23

jsumners opened this issue Jul 26, 2019 · 7 comments

Comments

@jsumners
Copy link

I'm running tap --no-coverage-report 'test/**/*.test.js' | npx tap-xunit against a suite of tests that has a failure and I'm not seeing any output. The installed tap version is 14.4.3.

@robcresswell
Copy link

I'm seeing the same; any luck making it work @jsumners ?

@jsumners
Copy link
Author

@robcresswell no. I haven't had time to get back to it and see which is the most recent version to work. @isaacs do you have any guesses?

@isaacs
Copy link

isaacs commented Aug 12, 2019

I'm not sure, but it looks like this does not have support for indented subtests, relying instead on comments to identify test suite boundaries. The current version of tap-parser is 9.2.2, and this module is using ~1.2.2, so it'll probably have to be significantly refactored to work properly.

Instead of using comments to identify suites, the latest tap-parser emits a child event with a tap-parser for the child test.

illustrative example
$ cat | tap-parser <<TAP
TAP version 13
ok 1
# Subtest: child test
    1..1
    ok
ok 2 - child test
1..2
TAP
[
  [ 'version', 13 ],
  [ 'assert', Result { ok: true, id: 1, fullname: '' } ],
  [
    'child',
    [
      [ 'comment', '# Subtest: child test\n' ],
      [ 'plan', { start: 1, end: 1 } ],
      [ 'assert', Result { ok: true, id: 1, fullname: 'child test' } ],
      [
        'complete',
        FinalResults {
          ok: true,
          count: 1,
          pass: 1,
          fail: 0,
          bailout: false,
          todo: 0,
          skip: 0,
          plan: FinalPlan {
            start: 1,
            end: 1,
            skipAll: false,
            skipReason: '',
            comment: ''
          },
          failures: []
        }
      ]
    ]
  ],
  [
    'assert',
    Result { ok: true, id: 2, name: 'child test', fullname: '' }
  ],
  [ 'plan', { start: 1, end: 2 } ],
  [
    'complete',
    FinalResults {
      ok: true,
      count: 2,
      pass: 2,
      fail: 0,
      bailout: false,
      todo: 0,
      skip: 0,
      plan: FinalPlan {
        start: 1,
        end: 2,
        skipAll: false,
        skipReason: '',
        comment: ''
      },
      failures: []
    }
  ]
]

Incidentally, as a workaround, this might actually make it sort of work: node test.js | tap-parser -t -f | tap-xunit. You'd lose subtests entirely, but at least the assertion names will still include the suite name. -t means "output TAP" and -f means "flatten".

tap-parser -t -f example
$ cat | tap-parser -t -f <<TAP
TAP version 13
ok 1 - okie dokie
# Subtest: child test
    1..1
    ok 1 - this is fine
ok 2 - child test
1..2
TAP

TAP version 13
ok 1 - okie dokie
ok 2 - child test > this is fine
1..2

@jsumners
Copy link
Author

Thank you. I'll give it a shot when I get some time.

@robcresswell
Copy link

That was fast; thanks @isaacs, will also give this a go.

@isaacs
Copy link

isaacs commented Aug 12, 2019

Probably would be a good idea for the sanitize method to turn > in test names into &gt;, depending on how strict the XML parsers are that you want to support. Most XML parsers accept > chars in a quoted attribute value, but I wouldn't depend on that.

@bencon
Copy link

bencon commented Nov 21, 2019

I'm running tap --no-coverage-report 'test/**/*.test.js' | npx tap-xunit against a suite of tests that has a failure and I'm not seeing any output. The installed tap version is 14.4.3.

The failure followed by output sounds like it could be the same issue that I was running into. If it is, PR https://github.com/aghassemi/tap-xunit/pull/26 provides a fix.

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

4 participants