-
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
Add docs for test parameter need to be named t
#1096
Conversation
@@ -63,6 +63,16 @@ test(async t => { | |||
|
|||
AVA [can't trace uncaught exceptions](https://github.com/avajs/ava/issues/214) back to the test that triggered them. Callback-taking functions may lead to uncaught exceptions that can then be hard to debug. Consider promisifying and using `async`/`await`, as in the above example. This should allow AVA to catch the exception and attribute it to the correct test. | |||
|
|||
### Why is the power-assert information not shown? | |||
|
|||
Ensure that the first parameter passed into your test is named `t`. This is a byproduct of the way power-assert works. It uses a pattern matching scheme that makes it easier for implementors to wrap any assertion library with power-assert goodness without having to understand the ES AST at all. See [#1031](https://github.com/avajs/ava/issues/1031) for more details. |
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.
This is a byproduct of the way power-assert works.
I'd rather say that "This is a requirement by power-assert.".
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.
Could you change this to:
Why are the enhanced assertion messages not shown?
Ensure that the first parameter passed into your test is named
t
. This is a requirement of how AVA usespower-assert
, the library that provides the enhanced messages. works.
I see that this paragraph originally comes from @jamestalmage's comment in #1031 (comment). It's quite technical though. I don't think we need that kind of detail 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.
I fully agree, that was just some blind copy and pasting from the comment on my part. Should I still keep the link to the issue for anyone who wants to know more?
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.
Nah, the issue still requires a lot of careful reading and background to fully understand why it is this way.
Good job explaining the what & why! |
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.
Thanks @gurpreetatwal! I feel the explanation is unnecessarily technical though. It's interesting background information, sure, but people just want to know how to make their test setup work.
Make the indentation style consistent in the code samples
I'm going to have to ask you to revert this, sorry. package.json
files require two-space indentation. (You could change it, but the next time npm writes that file it forces its indentation on you anyway.)
@@ -63,6 +63,16 @@ test(async t => { | |||
|
|||
AVA [can't trace uncaught exceptions](https://github.com/avajs/ava/issues/214) back to the test that triggered them. Callback-taking functions may lead to uncaught exceptions that can then be hard to debug. Consider promisifying and using `async`/`await`, as in the above example. This should allow AVA to catch the exception and attribute it to the correct test. | |||
|
|||
### Why is the power-assert information not shown? | |||
|
|||
Ensure that the first parameter passed into your test is named `t`. This is a byproduct of the way power-assert works. It uses a pattern matching scheme that makes it easier for implementors to wrap any assertion library with power-assert goodness without having to understand the ES AST at all. See [#1031](https://github.com/avajs/ava/issues/1031) for more details. |
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.
Could you change this to:
Why are the enhanced assertion messages not shown?
Ensure that the first parameter passed into your test is named
t
. This is a requirement of how AVA usespower-assert
, the library that provides the enhanced messages. works.
I see that this paragraph originally comes from @jamestalmage's comment in #1031 (comment). It's quite technical though. I don't think we need that kind of detail here.
```js | ||
test(t => { | ||
t.is(1, 1); | ||
} |
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.
Missing );
at the end here.
}, | ||
"devDependencies": { | ||
"ava": "^0.15.0" | ||
} |
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.
Could you revert these to their original two space indentation? It's how package.json
files are formatted.
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.
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. There should be no unrelated whitespace changes in this PR.
t
Thanks :) |
t
to make it stronger and explain why its required.Closes #1031