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

TS migration jest-circus #7916

Merged
merged 44 commits into from
Feb 22, 2019
Merged

TS migration jest-circus #7916

merged 44 commits into from
Feb 22, 2019

Conversation

doniyor2109
Copy link
Contributor

Summary

TS migration jest-circus

Test plan

WIP

@doniyor2109
Copy link
Contributor Author

NodeJS global does not work as I expected 🤔

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.

Awesome start!

packages/jest-circus/src/dts/co.d.ts Outdated Show resolved Hide resolved
packages/jest-circus/src/eventHandler.ts Show resolved Hide resolved
packages/jest-circus/src/eventHandler.ts Outdated Show resolved Hide resolved
packages/jest-circus/src/eventHandler.ts Outdated Show resolved Hide resolved
packages/jest-circus/src/eventHandler.ts Show resolved Hide resolved
packages/jest-circus/src/formatNodeAssertErrors.ts Outdated Show resolved Hide resolved
packages/jest-circus/src/types.ts Outdated Show resolved Hide resolved
packages/jest-circus/src/types.ts Outdated Show resolved Hide resolved
@SimenB
Copy link
Member

SimenB commented Feb 16, 2019

NodeJS global does not work as I expected 🤔

This doesn't work? https://github.com/facebook/jest/blob/c14a45d89d469c8bf226c5db62bac52d59597a9a/packages/jest-mock/src/index.ts#L10

@doniyor2109
Copy link
Contributor Author

#7916 (comment)
This doesn't work?

importing Global type is working but I cannot assign to global type for this case

https://github.com/facebook/jest/blob/d2023f120856314d5c3ca5b2661f894fda471384/packages/jest-circus/src/state.js#L37-L39

@doniyor2109
Copy link
Contributor Author

doniyor2109 commented Feb 17, 2019

importing Global type is working but I cannot assign to global type for this case

jest/packages/jest-circus/src/state.js

Lines 37 to 39 in d2023f1

global[STATE_SYM] = INITIAL_STATE;

It turns out TS does not support keys as symbols yet. There is workaround for it microsoft/TypeScript#24587 (comment). It is not great but it works for now

packages/jest-circus/package.json Outdated Show resolved Hide resolved
packages/jest-circus/src/eventHandler.ts Show resolved Hide resolved
packages/jest-circus/src/index.ts Outdated Show resolved Hide resolved
packages/jest-circus/src/run.ts Outdated Show resolved Hide resolved
packages/jest-circus/src/types.ts Outdated Show resolved Hide resolved
packages/jest-circus/src/utils.ts Show resolved Hide resolved
packages/jest-circus/src/utils.ts Outdated Show resolved Hide resolved
@codecov-io
Copy link

Codecov Report

Merging #7916 into master will increase coverage by 7.09%.
The diff coverage is 86.95%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #7916      +/-   ##
==========================================
+ Coverage   58.32%   65.42%   +7.09%     
==========================================
  Files         164      255      +91     
  Lines        6047     9949    +3902     
  Branches        5     1038    +1033     
==========================================
+ Hits         3527     6509    +2982     
- Misses       2518     3193     +675     
- Partials        2      247     +245
Impacted Files Coverage Δ
...st-core/src/getNoTestFoundRelatedToChangedFiles.js 0% <ø> (ø)
packages/jest-core/src/getNoTestFoundFailed.js 0% <ø> (ø)
packages/jest-core/src/TestWatcher.js 42.85% <ø> (ø)
packages/jest-cli/src/init/modify_package_json.js 100% <ø> (ø)
packages/jest-core/src/ReporterDispatcher.js 87.5% <ø> (ø)
packages/jest-core/src/plugins/quit.js 42.85% <ø> (ø)
packages/jest-core/src/TestNamePatternPrompt.js 44.44% <ø> (ø)
...t-core/src/plugins/update_snapshots_interactive.js 65.51% <ø> (ø)
packages/jest-cli/src/init/questions.js 100% <ø> (ø)
packages/jest-core/src/TestPathPatternPrompt.js 46.66% <ø> (ø)
... and 130 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c14a45d...6401264. Read the comment docs.

doniyor2109 and others added 4 commits February 17, 2019 18:04
Co-Authored-By: doniyor2109 <doniyor2109@gmail.com>
Co-Authored-By: doniyor2109 <doniyor2109@gmail.com>
Exported variable 'jestAdapter' has or is using name '$JestEnvironment' from external module "packages/jest-types/build/Environment" but cannot be named.

microsoft/TypeScript#5711

describe.each([['beforeEach'], ['beforeAll'], ['afterEach'], ['afterAll']])(
'%s hooks error throwing',
fn => {
(fn: 'beforeEach' | 'beforeAll' | 'afterEach' | 'afterAll') => {
Copy link
Member

Choose a reason for hiding this comment

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

would be cool to type jest-each so that it would be inferred.

/cc @mattphillips

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.

Thanks again for a the fantastic work! I've tweaked this a bit (as you probably noticed since we pushed at the same time), and I think this is good to go now. Gonna wait for someone else to review it as well, though 🙂

@SimenB SimenB changed the title [WIP] TS migration jest-circus TS migration jest-circus Feb 22, 2019
@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 12, 2021
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.

4 participants