-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
make expect.hasAssertions ignore skipped tests #3595
Comments
This particular piece of code is passing without issues. Can you provide some more information on it? Sample code will be really helpful |
So that does appear to work (I thought I tested that case and it was failing... but it's working for that case now). The case that is still failing for us is when we put |
Here's a failing test: describe('test', function() {
it.only('runs this test', function() {
expect.hasAssertions();
expect(1).toBe(1);
})
it('fails this test', function() {
expect(2).toBe(2);
});
}); Results:
|
I just encountered the same issue but from a different perspective. I have a bunch of stubbed/skipped tests that I have been filling out, and in one of the non-skipped tests I have an Here is a boiled down example: describe('my file', () => {
xdescribe('section A', () => {
xit('fill this out') // <--- test fails with "Expected at least one assertion to be called but received none."
xit('fill this out too') // <--- test fails with "Expected at least one assertion to be called but received none."
xit('fill this out as well') // <--- test fails with "Expected at least one assertion to be called but received none."
})
describe('section b', () => {
it('testing this one', () => {
expect.hasAssertions() // <--- the above tests fail when this line is present, but are skipped when it is not present
return myPromiseReturningFunc()
.then(result => expect(result).not.toBeNull())
})
})
}) |
Here is a simplified example of @bookman25's comment about using xdescribe('suite', () => {
expect.hasAssertions()
it('test', () => {
expect(true).toBe(true)
})
}) |
Just following up on whether there's plans to introduce this behaviour, or if someone is working on one already? Having |
Looks like as a result of #4498 this ticket should probably be closed. |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Do you want to request a feature or report a bug?
feature
What is the current behavior?
If you use
expect.hasAssertions()
inside of a skipped test, the test gets marked as failed. This includes if you usefit
on another test in the same spec file.What is the expected behavior?
It would be nice if
expect.hasAssertions()
was not enforced for skipped tests.Our use case is we have
expect.hasAssertions()
inside oursetupTestFrameworkScriptFile
so that every test is required to have at least one assertion. However sometimes when debugging an individual test we will usefit
and as a result all of the other tests in the spec file get marked as failures.The text was updated successfully, but these errors were encountered: