Skip to content
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

Merged
merged 2 commits into from
Apr 23, 2022
Merged

feat(jest-runner): export TestRunner interface types and reexport types from other packages #12715

merged 2 commits into from
Apr 23, 2022

Conversation

mrazauskas
Copy link
Contributor

Following up #12646

Summary

Just tried out jest-runner exports added in #12646. All works fine, but gave me somewhat clumsy feel ;D

Would be really useful to have types of other packages reexported. Also CallbackTestRunnerInterface and EmittingTestRunnerInterface would give more implementation flexibility for the user.

Test plan

Type tests added.

Comment on lines -9 to +13
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,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks way better.

Comment on lines +53 to +60
class CustomCallbackRunner implements CallbackTestRunnerInterface {
readonly #maxConcurrency: number;
readonly #globalConfig: Config.GlobalConfig;

constructor(globalConfig: Config.GlobalConfig) {
this.#globalConfig = globalConfig;
this.#maxConcurrency = globalConfig.maxWorkers;
}
Copy link
Contributor Author

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.

Copy link
Member

@SimenB SimenB left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!

@SimenB SimenB merged commit e72c52f into jestjs:main Apr 23, 2022
@mrazauskas mrazauskas deleted the feat-more-runner-types branch April 23, 2022 08:22
@mrazauskas
Copy link
Contributor Author

mrazauskas commented Apr 25, 2022

Tried it out. All very good. Especially happy about reexported types. Thanks for the idea!

@SimenB
Copy link
Member

SimenB commented Apr 25, 2022

yay!

F3n67u pushed a commit to F3n67u/jest that referenced this pull request May 2, 2022
@github-actions
Copy link

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.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 26, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants