Repository: skovhus/jest-codemods
Pull request #494 (2023-03-16 18:21:54)

Update dependency typescript to v5
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [typescript](https://www.typescriptlang.org/) ([source](https://togithub.com/Microsoft/TypeScript)) | [`4.9.5` -> `5.0.2`](https://renovatebot.com/diffs/npm/typescript/4.9.5/5.0.2) | [![age](https://badges.renovateapi.com/packages/npm/typescript/5.0.2/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/npm/typescript/5.0.2/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/npm/typescript/5.0.2/compatibility-slim/4.9.5)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/npm/typescript/5.0.2/confidence-slim/4.9.5)](https://docs.renovatebot.com/merge-confidence/) |

---

### Release Notes

<details>
<summary>Microsoft/TypeScript</summary>

### [`v5.0.2`](https://togithub.com/microsoft/TypeScript/releases/tag/v5.0.2): TypeScript 5.0

[Compare Source](https://togithub.com/Microsoft/TypeScript/compare/v4.9.5...v5.0.2)

For release notes, check out the [release announcement](https://devblogs.microsoft.com/typescript/announcing-typescript-5-0/).

For the complete list of fixed issues, check out the

-   [fixed issues query for Typescript v5.0.0 (Beta)](https://togithub.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=is%3Aissue+milestone%3A%22TypeScript+5.0.0%22+is%3Aclosed+).
-   [fixed issues query for Typescript v5.0.1 (RC)](https://togithub.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=is%3Aissue+milestone%3A%22TypeScript+5.0.1%22+is%3Aclosed+).
-   [fixed issues query for Typescript v5.0.2 (Stable)](https://togithub.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=is%3Aissue+milestone%3A%22TypeScript+5.0.2%22+is%3Aclosed+).

Downloads are available on:

-   [npm](https://www.npmjs.com/package/typescript)
-   [NuGet package](https://www.nuget.org/packages/Microsoft.TypeScript.MSBuild)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/skovhus/jest-codemods).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNS45LjAiLCJ1cGRhdGVkSW5WZXIiOiIzNS4xNy4xIn0=-->


codecov[bot]: ## [Codecov](https://codecov.io/gh/skovhus/jest-codemods/pull/494?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Kenneth+Skovhus) Report
Patch and project coverage have no change.
> Comparison is base [(`1441a6a`)](https://codecov.io/gh/skovhus/jest-codemods/commit/1441a6ae191d7dd2f32cb4a9abead0099947126f?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Kenneth+Skovhus) 92.39% compared to head [(`b25baee`)](https://codecov.io/gh/skovhus/jest-codemods/pull/494?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Kenneth+Skovhus) 92.39%.

<details><summary>Additional details and impacted files</summary>


```diff
@@           Coverage Diff           @@
##             main     #494   +/-   ##
=======================================
  Coverage   92.39%   92.39%           
=======================================
  Files          26       26           
  Lines        1934     1934           
  Branches      404      404           
=======================================
  Hits         1787     1787           
  Misses        101      101           
  Partials       46       46           
```



Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Kenneth+Skovhus). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Kenneth+Skovhus)

</details>

[:umbrella: View full report in Codecov by Sentry](https://codecov.io/gh/skovhus/jest-codemods/pull/494?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Kenneth+Skovhus).   
:loudspeaker: Do you have feedback about the report comment? [Let us know in this issue](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Kenneth+Skovhus).


Patch:
diff --git a/package.json b/package.json
index f330a15..b10f22b 100644
--- a/package.json
+++ b/package.json
@@ -79,7 +79,7 @@
     "lint-staged": "13.2.0",
     "prettier": "2.8.6",
     "ts-jest": "29.0.5",
-    "typescript": "4.9.5"
+    "typescript": "5.0.2"
   },
   "jest": {
     "preset": "ts-jest",
diff --git a/src/transformers/chai-should.ts b/src/transformers/chai-should.ts
index a5e9660..c02fb62 100644
--- a/src/transformers/chai-should.ts
+++ b/src/transformers/chai-should.ts
@@ -197,6 +197,10 @@ export default function transformer(fileInfo, api, options) {
 
   const isExpectCall = (node) => isExpectCallUtil(j, node)
 
+  const isInsideExpectCall = (path) =>
+    findParentOfType(path.parentPath.parentPath, 'CallExpression')?.value.callee.name ===
+    'expect'
+
   const typeOf = (path, value, args, containsNot) => {
     switch (args[0].value) {
       case 'null':
@@ -398,6 +402,7 @@ export default function transformer(fileInfo, api, options) {
           },
         })
         .filter((p) => findParentOfType(p, 'ExpressionStatement'))
+        .filter((p) => !isInsideExpectCall(p))
         .filter((p) => {
           const { value } = p
           const propertyName = value.property.name.toLowerCase()
diff --git a/yarn.lock b/yarn.lock
index a085a2f..6588fd8 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -5173,10 +5173,10 @@ typedarray-to-buffer@^3.1.5:
   dependencies:
     is-typedarray "^1.0.0"
 
-typescript@4.9.5:
-  version "4.9.5"
-  resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.9.5.tgz#095979f9bcc0d09da324d58d03ce8f8374cbe65a"
-  integrity sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==
+typescript@5.0.2:
+  version "5.0.2"
+  resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.0.2.tgz#891e1a90c5189d8506af64b9ef929fca99ba1ee5"
+  integrity sha512-wVORMBGO/FAs/++blGNeAVdbNKtIh1rbBL2EyQ1+J9lClJ93KiiKe8PmFIVdXhHcyv44SL9oglmfeSsndo0jRw==
 
 unique-string@^2.0.0:
   version "2.0.0"


Test patch:
diff --git a/src/transformers/chai-should.test.ts b/src/transformers/chai-should.test.ts
index 70e218a..d99db08 100644
--- a/src/transformers/chai-should.test.ts
+++ b/src/transformers/chai-should.test.ts
@@ -302,11 +302,13 @@ test('converts "called"', () => {
   expectTransformation(
     `
         expect(sinonSpy).to.be.called;
+        expect(sinonSpy).to.be.called();
         expect(sinonSpy).not.to.be.called;
         expect(sinonSpy).to.not.be.called;
         expect(sinonSpy).to.be.not.called;
     `,
     `
+        expect(sinonSpy).toHaveBeenCalled();
         expect(sinonSpy).toHaveBeenCalled();
         expect(sinonSpy).not.toHaveBeenCalled();
         expect(sinonSpy).not.toHaveBeenCalled();
@@ -315,6 +317,19 @@ test('converts "called"', () => {
   )
 })
 
+test('does not convert "fetchMock.called()"', () => {
+  expectTransformation(
+    `
+        expect(fetchMock.called("/url")).to.equal(true);
+        expect(fetchMock.called()).to.equal(true);
+    `,
+    `
+        expect(fetchMock.called("/url")).toBe(true);
+        expect(fetchMock.called()).toBe(true);
+    `
+  )
+})
+
 test('converts "called.exactly(n)"', () => {
   expectTransformation(
     `