-
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
[WIP] A way to submit tests that should fail. #831
[WIP] A way to submit tests that should fail. #831
Conversation
By analyzing the blame information on this pull request, we identified @ariporad, @sotojuan and @BarryThePenguin to be potential reviewers |
There needs to be a test that makes the tests fail when a test passes I'd say. |
Agreed, needs quite a few more tests.
|
Just for tracking
|
Any reason you haven't tackled the last two? // this should pass
test.failing(t => {
t.throws(Promise.resolve('foo'));
});
// this should fail
test.failing(t => {
t.notThrows(Promise.resolve('foo'));
}); |
Cause they failed... |
This should fix your failing test: diff --git a/test/test.js b/test/test.js
index d2f3f1b..9fd23a9 100644
--- a/test/test.js
+++ b/test/test.js
@@ -676,10 +676,10 @@ test('failing test with t.throws(nonThrowingPromise) is passing', function (t) {
test('failing test with t.throws(throws) is failure', function (t) {
ava.failing(function (a) {
- a.throws(Promise.resolve('foo'));
+ a.notThrows(Promise.resolve('foo'));
}).run().then(function (result) {
t.is(result.passed, false);
- t.is(result.message, failingTestHint);
+ t.is(result.reason.message, failingTestHint);
t.end();
});
}); You should update the test title with |
😅Aha, not the first time making such embarrassing mistake |
Awesome! LGTM! |
@cgcgbcbc - Can you add documentation for this to the Readme? |
@jamestalmage , do you think it's necessary to check that the failing modifier can only be used with test and throws error when used with hooks? |
No, it's conceivable you could write an test.failing.afterEach('always leaves X in pristine state', t => {
t.true(isPristine(t.context.state));
}); That's enough of a corner case that it should probably be flagged by the linter though. Can you open an issue in |
Do you mean the no-unknown-modifiers rule as I mentioned in avajs/eslint-plugin-ava#107 ? |
I just did it: avajs/eslint-plugin-ava#108 |
@@ -415,6 +415,16 @@ You can use the `.todo` modifier when you're planning to write a test. Like skip | |||
test.todo('will think about writing this later'); | |||
``` | |||
|
|||
### Failing tests | |||
|
|||
You can use the `.failing` modifier for submitting tests that are intended to be failures without killing CI process. And if the failing test does pass, it will fail, and it will remind you remove the failing modifier. |
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 would like to expand on this a bit:
You can use the
.failing
modifier to document issues with your code that need to be fixed. Failing tests are run just like normal ones, but they are expected to fail, and will not break your build when they do. If a test marked asfailing
actually passes, it will be reported as an error and fail the build with a helpful message instructing you to remove the.failing
modifier.This allows you to merge
.failing
tests before a fix is implemented without breaking CI. This is a great way to recognize good bug report PR's with a commit credit, even if the reporter is unable to actually fix the problem.
@jamestalmage Thank you for your advice! I've fixed the documents. |
This looks great to me! Just need a second reviewer to merge. // @sindresorhus @novemberborn @vdemedes @sotojuan |
Looks good @cgcgbcbc! I have some nits but will follow up with a PR rather than putting you through more back-and-forth 😄 |
Thanks @cgcgbcbc! |
see #673