-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
TAP support #326
TAP support #326
Conversation
|
||
module.exports = Assert; | ||
|
||
var x = Assert.prototype; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to remove this.
Looks very promising! :) 🍰
What specifically needs to be decided on? |
api.skip[el] = skipFn; | ||
api[el] = function () { | ||
try { | ||
var fn = assert[el].apply(assert, arguments); | ||
var fn = self.assert[el].apply(self.assert, arguments); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have to make assert
a class? Can't we just track assertions here? Demanding the assert class track assertions is going to make it harder to support custom assertions down the road.
Is the issue simply that it is hard to know which argument is the message here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have to make assert a class? Can't we just track assertions here?
I'm open to suggestions!
Demanding the assert class track assertions is going to make it harder to support custom assertions down the road.
It will, see my comment below.
Is the issue simply that it is hard to know which argument is the message here?
The issue lies in AVA's feature - concurrency. As you know, tests run concurrently, so we have to track which assertions happened during that particular test. That's why Assert
class is needed, because that way we can safely get a list of test's assertions.
Sorry for not making that clear. We need to decide what title do we display for assertions:
So, test have titles and assertion have titles too, so we need to decide on the latter. |
|
@vdemedes - I know I linked it before somewhere, but here are the docs you need for the FYI: @twada keeps stuff he still considers "beta" under his GitHub account and only moves stuff to the As for Finally, we are going to need to come up with a solution for assertions like this: t.same(foo, {
blah: 'blah',
bar: 'foo',
zippo: [1, 2, 3]
}); That is probably a more than we want to log, even when compacted to a single line. We can probably do some pretty clever collapsing of the code eventually (i.e. For the first pass, maybe we don't use the |
For multiline assertions, power-assert normalizes the assertion lines to single line to render diagrams on reporting. For example, In @jamestalmage's case, |
Yes, my point was that even that will end up verbose given a large enough object declaration. I'm sure our eventual solution will share code with SuccinctReporter. |
@@ -20,13 +21,14 @@ function Test(title, fn) { | |||
title = null; | |||
} | |||
|
|||
assert.is(typeof fn, 'function', 'you must provide a callback'); | |||
assert.equal(typeof fn, 'function', 'you must provide a callback'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick, but equal
=> strictEqual
@jamestalmage So I tried to use latest changes to assertions and turned out it's not actually usable for tracking assertions. I inserted { originalMessage: undefined,
enhanced: true,
args: [ true, undefined ],
assertionThrew: false,
returnValue: undefined }
The assertion is a simple |
I looked into this a bit. These will not attach a powerAssertContext: t.ok(true);
t.is('a', 'a'); These will: var a = 'a';
t.ok(a);
t.is(a, 'a');
t.is({a: 'a'}.a, 'a'); It should still be possible to build something close to the original source using |
I don't think this will have good consequences, we need a stable solution. Otherwise we'll end up with a babel-like stream of issues. |
Can we defer the assert title complications for later and focus on just getting some TAP output in this PR? We can just go for naive assert titles for now. |
👍 It's (no tap) the only thing that's preventing me from deep diving into Ava :) |
I agree. I think it will take us a while to figure that out correctly, and I don't want to hold up TAP support. Unfortunately, |
Ok, let's postpone it for now, I'll come up with something simpler. I'm off tomorrow, so I'll post updates the day after. @jamestalmage will take a look, thanks. |
Alright. I've opened an issue for it so we don't forget. #341 |
74673c1
to
736a044
Compare
PR updated with additions to Readme. Now it can be merged and we'll handle assertion output later. |
|
||
AVA can generate TAP output via `--tap` option for use with any 3rd-party reporters. | ||
|
||
```bash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't use bash
as it's not valid shell script with the $
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was using it, because sometimes it highlights executable name and symbols like |
. Will remove it, no probs ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but the highlighting is very random.
output.push(' ...'); | ||
|
||
console.log(output.join('\n')); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think something like this would look nicer:
console.log([
'# ' + err.message,
format('not ok %d - %s', ++i, err.message),
' ---',
' name: ' + err.name,
' at: ' + getSourceFromStack(err.stack, 1),
' ...'
].join('\n'));
Can you add some tests? |
And add |
AVA can generate TAP output via `--tap` option for use with any 3rd-party reporters. | ||
|
||
```bash | ||
$ ava --tap | tap-spec |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be more fun to illustrate with the nyan
reporter, right? You also need to show installing the reporter. Otherwise we'll end up with support issues on how it doesn't work...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we include a screenshot or that'd be too much?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, drop the install instruction. We can't know if they want to use it locally or globally. It has to be globally installed if used like the above, or locally if used in a npm run script.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will! |
I'm thinking if we should return generated output from |
👍 |
7639370
to
cccb2cd
Compare
PR updated according to all suggestions:
|
@@ -36,7 +37,8 @@ var cli = meow([ | |||
' --init Add AVA to your project', | |||
' --fail-fast Stop after first test failure', | |||
' --serial Run tests serially', | |||
' --require Module to preload (Can be repeated)', | |||
' --require Module to preload (Can be repeated)',, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
double comma
LGTM |
⬆️ Can you open an issue for this? |
I'm surprised there's no compliance suite any TAP producer could use. Would be so useful (hint hint). Something like https://github.com/promises-aplus/promises-tests |
LGTM I have run it against a number of projects, and the output looks great when everything passes. Something feels off when there are errors though:
tail end of Neither tells you which test the failure came from (these are not uncaught exceptions, but assertion errors). |
👍 LGTM We can improve the messages incrementally. |
I figured there's no need for this one, as we end the tests "safely". And not all reporters handle this stuff. @jamestalmage Try to use |
@sindresorhus good idea! |
cccb2cd
to
d765dc2
Compare
@sindresorhus @jamestalmage guys, need you to LGTM one more time. It does not want to merge it otherwise. |
@sindresorhus @jamestalmage Never mind, merged! |
This PR fixes #27.
It adds
--tap
flag to a CLI to generate TAP-compatible output, which can then be used with any 3rd-party reporters.Here are the things to be resolved before this PR can be merged:
test/assert.js
Bail out!
Let's discuss!