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
Allowed functions in jest's describe #23102
Allowed functions in jest's describe #23102
Conversation
As of 22.0.5, jest allows classes for describe blocks.
@JoshuaKGoldberg Thank you for submitting this PR! 🔔 @NoHomey @jwbay @asvetliakov @alexjoverm @epicallan @ikatyang @wsmd @JamieMason @douglasduteil @AhnpGit - please review this PR in the next few days. Be sure to explicitly select If no reviewer appears after a week, a DefinitelyTyped maintainer will review the PR instead. |
@JoshuaKGoldberg The Travis CI build failed! Please review the logs for more information. Once you've pushed the fixes, the build will automatically re-run. Thanks! |
types/jest/index.d.ts
Outdated
@@ -199,6 +199,10 @@ declare namespace jest { | |||
|
|||
type Lifecycle = (fn: ProvidesCallback, timeout?: number) => any; | |||
|
|||
interface IClassLike { |
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.
What do you think about calling this interface FunctionLike
?
Since classes are technically "special functions" and the describe
implementation obviously works functions as well, I think FunctionLike
would be better here for the sake of clarity.
I'm thinking about the following scenarios:
const myInstance = new SomeClass();
describe(myInstance.constructor /* I don't know what you would do that but whatever 😅 */, () => {
// ...
});
function doSomething() {
// ...
}
describe(doSomething, () => {
// ...
});
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.
SGTM! Made the change.
I also added Function
to the allowed type union because some projects don't provide a name
string in their Function
typings (since it doesn't exist in IE).
@JoshuaKGoldberg - It appears Travis did not correctly run on this PR! /cc @RyanCavanaugh to investigate and advise. |
|
Ehh, I don't think my changes are causing the failures... @RyanCavanaugh |
types/jest/index.d.ts
Outdated
|
||
declare var beforeAll: jest.Lifecycle; |
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.
why did you remove this ?
types/jest/index.d.ts
Outdated
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped | ||
// TypeScript Version: 2.3 |
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.
Please put this back, Travis failed because it couldn't find this line.
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.
Spooky - must have been a bad merge...
🔔 @AhnpGit - Thanks for your review of this PR! Can you please look at the new code and update your review status if appropriate? |
A definition author has approved this PR ⭐️. A maintainer will merge this PR shortly. If it shouldn't be merged yet, please leave a comment saying so and we'll wait. Thank you for your contribution to DefinitelyTyped! |
As of 22.0.5, jest allows classes for describe blocks.
Please fill in this template.
npm run lint package-name
(ortsc
if notslint.json
is present).Select one of these and delete the others:
If changing an existing definition: