-
-
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
Feature Request: Throw error if first argument to "it" or "test" is not a string #5493
Comments
Yeah, do you wanna send a PR to make this throw? :) |
@cpojer I'd love to. Thanks for the feedback. |
Can I do this? |
@brianmacdonald sure |
@reggi Please correct me if I'm off base, but from what I can tell, jest-Jasmine2 is running 'test' and 'it', and not jest-circus, which, I'm assuming will eventually replace jest-Jasmine2. So should I get the errors to throw in both places? Or just one? |
Both would be great!
|
Is it possible to not do this behavior, or at the very least, put the ability to toggle it off? Maybe my use case isn't common, but I find myself writing out a bunch of test cases first, then I begin implementing them. Getting an error thrown in that scenario clutters up the terminal with errors about "Missing second argument. It must be a callback function". Thanks! |
I agree with @mike-robertson. It's super common in TDD to write the specs first and then implement the behavior. I don't know how this change went through. I'll open a separate issue. |
Ditto what @mike-robertson said; the missing second function is (was) a deliberate feature to allow skipped tests and I use it in exactly the way that he describes, writing out test cases to be written as I think about it and filling them in later. It seems that #5558 should have checked that the first arg was a string rather than checking that two args were passed... |
Workaround for this now is to pass in an empty function in addition to Previously I could do: test('Test to be written') But that throws now, so I have to do: test.skip('Test to be written', () => {}) Which works, but seems much more verbose. Was this intentional? |
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. |
Coming from ava, you don't need test descriptions.
The following would work.
However, this doesn't do anything in jest.
Can we throw an error if there is no function as the second argument? Or if a string is not passed into the first?
The text was updated successfully, but these errors were encountered: