-
-
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
Add projectConfig argument to shouldRunTestSuite hook #6350
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,11 +61,11 @@ class JestHooks { | |
this._listeners.onTestRunComplete.forEach(listener => | ||
listener(results), | ||
), | ||
shouldRunTestSuite: async testPath => | ||
shouldRunTestSuite: async (testPath, config) => | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another option for this would be to change the signature to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Although this would mean an initial breaking change, which should probably only affect There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I hope people will understand it's still getting in shape ;) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can call it out in the blog post as still somewhat experimental? |
||
Promise.all( | ||
this._listeners.shouldRunTestSuite.map(listener => | ||
listener(testPath), | ||
), | ||
this._listeners.shouldRunTestSuite.map(listener => { | ||
return listener(testPath, config); | ||
}), | ||
).then(result => | ||
result.every(shouldRunTestSuite => shouldRunTestSuite), | ||
), | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,10 @@ export type JestHookExposedFS = { | |
}; | ||
|
||
export type FileChange = (fs: JestHookExposedFS) => void; | ||
export type ShouldRunTestSuite = (testPath: string) => Promise<boolean>; | ||
export type ShouldRunTestSuite = ( | ||
testPath: string, | ||
config: ProjectConfig, | ||
) => Promise<boolean>; | ||
export type TestRunComplete = (results: AggregatedResult) => void; | ||
|
||
export type JestHookSubscriber = { | ||
|
@@ -27,5 +30,8 @@ export type JestHookSubscriber = { | |
export type JestHookEmitter = { | ||
onFileChange: (fs: JestHookExposedFS) => void, | ||
onTestRunComplete: (results: AggregatedResult) => void, | ||
shouldRunTestSuite: (testPath: string) => Promise<boolean>, | ||
shouldRunTestSuite: ( | ||
testPath: string, | ||
config: ProjectConfig, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, from the discussion above I could see the type here being |
||
) => Promise<boolean>, | ||
}; |
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.
How about passing a stripped information about test, e.g.
({path, duration, config})
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.
+1
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.
Yeah that seems like the best idea
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.
Although duration is not always present, right?