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
Proposed changes for malformed tests #9515
Comments
seems reasonable. Right now we throw, which is why it stops where it does. Instead marking the tests as failing and moving on might make sense. Would you be willing to work on this feature? At least for circus, I don't really care about Jasmine. Current throwing logic lives here: https://github.com/facebook/jest/blob/964dc1619b8c5345a648ef79bcd87c087995255a/packages/jest-circus/src/index.ts |
Yes, I'm keen to have a go at it. I have already played with the code, but in |
If you're willing to also fix it in jest-jasmine that's great 👍 Any changes must also land in circus though, as we'll be deprecating the jasmine runner at some point 🙂 |
Any questions about what jasmine/circus are / how they relate to each other let us know, this has been confusing for many contributors |
Might be an idea to write some prose for the website (^ not me volunteering) |
Hey quick question. I'm working on updating the unit tests for this change in behaviour and I'm hitting an issue. Jest prevents you from nesting a test within another test. There are existing unit tests for the it/test function e.g.: it(`it throws error with missing callback function`, () => {
expect(() => {
it('test1');
}).toThrowError(
'Missing second argument. It must be a callback function. Perhaps you want to use `test.todo` for a test placeholder.',
);
}); This works fine because the existing implementation throws the exception as expected. However, because I'm now changing that behaviour to not throw, I'm now hitting an issue with testing a test framework with itself. Jest prevents tests from being nested and the nesting check is performed after the code previously would have thrown the expected error, which is why the test works. Note that this is for the Jasmine side of things. Circus it/test is tested with Jasmine so it gets around the nesting issue. Any thoughts on how to fix this? |
I think I'll ensure that the e2e tests cover this and remove the unit tests. |
Yes, I think removing this unit test is fine (as 'throws with missing callback function' is no longer the desired behavior, it should now 'collect the missing callback function error and proceed and throw it at the end') as long as a new test (e2e/unit/whatever kind) is added :) |
This issue is stale because it has been open for 1 year with no activity. Remove stale label or comment or this will be closed in 14 days. |
This issue was closed because it has been stalled for 7 days with no activity. Please open a new issue if the issue is still relevant, linking to this one. |
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. |
🚀 Feature Proposal
A change to the way that malformed tests are handled (e.g. don't have expected arguments) by running as much of the code as possible to provide the user as much useful information about what went wrong and how to fix it.
Motivation
This is dealing with an edge case, where tests have not been implemented correctly. This typically is due to missing arguments, or using the wrong argument types. Currently the tests stop executing at the first error that is encountered in a test file. I think it would be more helpful to the user if they had feedback on all potential issues in a single test run, rather than only being directed to the first issue.
Example
Here are some examples of malformed tests:
This is the current output:
Pitch
Notice how the execution of the tests is halted at the first error in the file. Personally I would like it if it ran as much of the code as possible, highlighting all the areas that there are issues. Obviously this excludes failures in syntax (missing braces/parens etc).
Here is the output with my proposed changes applied (same test code):
The text was updated successfully, but these errors were encountered: