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): improve typings by exposing TestRunner abstract classes #12646

Merged
merged 17 commits into from
Apr 8, 2022
Merged

feat(jest-runner): improve typings by exposing TestRunner abstract classes #12646

merged 17 commits into from
Apr 8, 2022

Conversation

mrazauskas
Copy link
Contributor

@mrazauskas mrazauskas commented Apr 7, 2022

Following up #12641

Summary

jest-core supports two kinds of test runner. What if jest-runner would expose two abstract classes, which would help to implement either kind of the runner?

For instance create-jest-runner could use these types here. Not to say that I would like to have this for my test runner ;D

Todo:

  • add type tests to prove all works as expected
  • documentation would be nice too

Test plan

Green CI.

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.

Oh yeah, this is awesome!

(Changelog?)

packages/jest-runner/src/index.ts Outdated Show resolved Hide resolved
const runnerContext = {} as TestRunnerContext;

class CallbackRunner extends CallbackTestRunner {
async runTests(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was hoping that override here in a test could catch some drift (hence #12648). Apparently override has no effect in this case, because methods are marked abstract.

In the other hand, abstract requires to implement those methods in a derived class. So to have this test passing is still good.

@mrazauskas mrazauskas requested a review from SimenB April 8, 2022 08:05
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.

wonderful!

@SimenB SimenB merged commit 420ba45 into jestjs:main Apr 8, 2022
@mrazauskas mrazauskas deleted the feat-test-runner-types branch April 8, 2022 08:40
@SimenB
Copy link
Member

SimenB commented May 3, 2022

@mrazauskas wanna take a stab at a PR in create-jest-runner that uses this? 🙂

@mrazauskas
Copy link
Contributor Author

Yes, I was looking at it already. Will do it after finishing jest.Mocked (which is all working already, I just want to write more tests).

@SimenB
Copy link
Member

SimenB commented May 3, 2022

Awesome 🎉

@github-actions
Copy link

github-actions bot commented Jun 3, 2022

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 Jun 3, 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