jest-native icon indicating copy to clipboard operation
jest-native copied to clipboard

refactor: Migrate codebase to typescript

Open Ne3l opened this issue 1 year ago • 1 comments

What:

closes #81.

Why:

Typescript provide type safety and ease of use for developers.

How:

As the repository is quite small, migrated all in once.

Use typescript compiler instead of babel to create the dist build. (Babel with react-native-metro preset is optimised to run JS on hermes/jsc not node but it can be configured for it)

Still some parts of the code are not 100% solved but i believe this is a good base to iterate on.

Checklist:

  • [ ] Add typescript check step on github actions
  • [ ] Ensure new build output is good for node14.
  • [ ] Solve @ts-ignore comments
    • [ ] https://github.com/Ne3l/jest-native/blob/typescriptMigration/src/tests/utils.ts
    • [ ] https://github.com/Ne3l/jest-native/blob/typescriptMigration/src/to-have-style.ts
    • [ ] https://github.com/Ne3l/jest-native/blob/typescriptMigration/src/utils.ts#L130
    • [ ] https://github.com/Ne3l/jest-native/blob/typescriptMigration/src/tests/to-be-disabled.tsx
  • [ ] Check no breaking change is done(To solve some issues that typescript spotted i had to refactor the code. maybe a breaking change was introduced(i think not but a second check it's welcome))

Ne3l avatar Aug 15 '22 20:08 Ne3l

Codecov Report

Merging #101 (bb67f0f) into main (d38fc80) will not change coverage. The diff coverage is 100.00%.

@@            Coverage Diff            @@
##              main      #101   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            8         8           
  Lines          149       151    +2     
  Branches        45        47    +2     
=========================================
+ Hits           149       151    +2     
Flag Coverage Δ
node-14 100.00% <100.00%> (ø)
node-16 100.00% <100.00%> (ø)
node-18 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/extend-expect.ts 100.00% <100.00%> (ø)
src/to-be-disabled.ts 100.00% <100.00%> (ø)
src/to-be-empty-element.ts 100.00% <100.00%> (ø)
src/to-contain-element.ts 100.00% <100.00%> (ø)
src/to-have-prop.ts 100.00% <100.00%> (ø)
src/to-have-style.ts 100.00% <100.00%> (ø)
src/to-have-text-content.ts 100.00% <100.00%> (ø)
src/utils.ts 100.00% <100.00%> (ø)

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

codecov[bot] avatar Aug 15 '22 20:08 codecov[bot]

@mdjastrzebski Thanks for reviewing, i'm on holidays now but will take a look at the MR at the beginning of september

Ne3l avatar Aug 19 '22 11:08 Ne3l

@mdjastrzebski I think i answer/fix all the open threads, please take a look.

Ne3l avatar Sep 11 '22 19:09 Ne3l

@mdjastrzebski Not sure what's the etiquette on this repo, but can you resolve the comments that are fixed and take a look at the rest? i've rebased the changes of https://github.com/testing-library/jest-native/pull/110.

Ne3l avatar Sep 18 '22 20:09 Ne3l

@Ne3l I've closed comments that I think are resolved. Sometimes it's hard to easily figure out if the given comment is solved or not, as they disappear from "Files changed" view.

mdjastrzebski avatar Sep 19 '22 21:09 mdjastrzebski

Hi @mdjastrzebski it's me again 😅 i have fixed most of your comments except the narrow one as i'm not sure i understand what do you mean.

Lets hope this is the good and we can merge this typescript setup as rebasing each new commit is a bit of a pain in the ass.

Ne3l avatar Sep 26 '22 18:09 Ne3l

@Ne3l I've reviewed the changes and made some minor tweaks to adjust typing or restore original logic where appropriate. Pls take a look at the changes if everything looks good, we can plan merging it tomorrow.

I am wondering whether to release this as a new major version/breaking change. The reasoning behind it is that we tweaked some external types and this might cause user tests to fail.

On the other hand the logic of all of the matchers should stay the same, so minor version bump could also do.

mdjastrzebski avatar Sep 28 '22 13:09 mdjastrzebski

LGTM

regarding the imports i saw you done some ordering. There is an eslint plugin for it that you may want to use https://eslint.org/docs/latest/rules/sort-imports

Ne3l avatar Sep 28 '22 16:09 Ne3l

:tada: This PR is included in version 5.0.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

github-actions[bot] avatar Sep 30 '22 10:09 github-actions[bot]