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

Conversation

@doniyor2109
Copy link
Contributor

doniyor2109 commented Feb 16, 2019

Summary

TS migration jest-circus

Test plan

WIP

@doniyor2109

This comment has been minimized.

Copy link
Contributor Author

doniyor2109 commented Feb 16, 2019

NodeJS global does not work as I expected 🤔

Copy link
Collaborator

SimenB left a comment

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

This comment has been minimized.

Copy link
Collaborator

SimenB commented Feb 16, 2019

NodeJS global does not work as I expected 🤔

This doesn't work?

type Global = NodeJS.Global; // | Window – add once TS improves typings;

doniyor2109 and others added 6 commits Feb 17, 2019
Co-Authored-By: doniyor2109 <doniyor2109@gmail.com>
@doniyor2109

This comment has been minimized.

Copy link
Contributor Author

doniyor2109 commented Feb 17, 2019

#7916 (comment)
This doesn't work?

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

global[STATE_SYM] = INITIAL_STATE;

@doniyor2109

This comment has been minimized.

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

This comment has been minimized.

Copy link

codecov-io commented Feb 17, 2019

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 Feb 17, 2019
Co-Authored-By: doniyor2109 <doniyor2109@gmail.com>
Co-Authored-By: doniyor2109 <doniyor2109@gmail.com>
doniyor2109 added 7 commits Feb 21, 2019
- Added Global and Environment types
- Workaround for RawMatcherFn type
doniyor2109 added 3 commits Feb 22, 2019
Exported variable 'jestAdapter' has or is using name '$JestEnvironment' from external module "packages/jest-types/build/Environment" but cannot be named.

microsoft/TypeScript#5711
doniyor2109 added 2 commits Feb 22, 2019

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

This comment has been minimized.

Copy link
@SimenB

SimenB Feb 22, 2019

Collaborator

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

/cc @mattphillips

SimenB added 2 commits Feb 22, 2019
…rcus/ts_migration
@SimenB SimenB requested review from aaronabramov and thymikee Feb 22, 2019
SimenB and others added 4 commits Feb 22, 2019
@SimenB
SimenB approved these changes Feb 22, 2019
Copy link
Collaborator

SimenB left a comment

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 requested review from palmerj3 and mattphillips Feb 22, 2019
@SimenB SimenB changed the title [WIP] TS migration `jest-circus` TS migration `jest-circus` Feb 22, 2019
@SimenB SimenB merged commit e998c92 into facebook:master Feb 22, 2019
0 of 12 checks passed
0 of 12 checks passed
ci/circleci: lint-and-typecheck CircleCI is running your tests
Details
ci/circleci: test-browser CircleCI is running your tests
Details
ci/circleci: test-jest-circus CircleCI is running your tests
Details
ci/circleci: test-node-10 CircleCI is running your tests
Details
ci/circleci: test-node-11 CircleCI is running your tests
Details
ci/circleci: test-node-6 CircleCI is running your tests
Details
ci/circleci: test-node-8 CircleCI is running your tests
Details
ci/circleci: test-or-deploy-website CircleCI is running your tests
Details
continuous-integration/appveyor/pr Waiting for AppVeyor build to complete
Details
continuous-integration/travis-ci/pr The Travis CI build is in progress
Details
deploy/netlify Deploy preview processing.
Details
facebook.jest in progress
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.