-
-
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
feat(jest-runner): export TestRunner
interface types and reexport types from other packages
#12715
Conversation
import type {Test, TestEvents} from '@jest/test-result'; | ||
import type {Config} from '@jest/types'; | ||
import {CallbackTestRunner, EmittingTestRunner} from 'jest-runner'; | ||
import type { | ||
CallbackTestRunnerInterface, | ||
Config, | ||
EmittingTestRunnerInterface, |
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.
Looks way better.
class CustomCallbackRunner implements CallbackTestRunnerInterface { | ||
readonly #maxConcurrency: number; | ||
readonly #globalConfig: Config.GlobalConfig; | ||
|
||
constructor(globalConfig: Config.GlobalConfig) { | ||
this.#globalConfig = globalConfig; | ||
this.#maxConcurrency = globalConfig.maxWorkers; | ||
} |
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.
Note that context
is omitted in constructor and members are named differently than in extends CallbackTestRunner
example above. It is possible have implements CallbackTestRunner
too, but then this sweet flexibility is not allowed. This code is from my actual use case. Learned something new.
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.
nice!
Tried it out. All very good. Especially happy about reexported types. Thanks for the idea! |
yay! |
…ypes from other packages (jestjs#12715)
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Following up #12646
Summary
Just tried out
jest-runner
exports added in #12646. All works fine, but gave me somewhat clumsy feel ;DWould be really useful to have types of other packages reexported. Also
CallbackTestRunnerInterface
andEmittingTestRunnerInterface
would give more implementation flexibility for the user.Test plan
Type tests added.