Repository: skovhus/jest-codemods
Pull request #337 (2022-07-20 18:46:00)

feat: adds deepStrictEqual to Chai Assert list
Even though Chai docs doesn't display the use of `deepStrictEqual`. It is a valid assertion and follows the `assert` model.

This PR adds the transform equivalent for jest.

codecov[bot]: # [Codecov](https://codecov.io/gh/skovhus/jest-codemods/pull/337?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Kenneth+Skovhus) Report
> Merging [#337](https://codecov.io/gh/skovhus/jest-codemods/pull/337?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Kenneth+Skovhus) (57f17c2) into [main](https://codecov.io/gh/skovhus/jest-codemods/commit/de5ab1b16716d0ca1327ebe9e1128be3fc90835e?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Kenneth+Skovhus) (de5ab1b) will **not change** coverage.
> The diff coverage is `n/a`.

```diff
@@           Coverage Diff           @@
##             main     #337   +/-   ##
=======================================
  Coverage   92.09%   92.09%           
=======================================
  Files          26       26           
  Lines        1872     1872           
  Branches      393      393           
=======================================
  Hits         1724     1724           
  Misses        102      102           
  Partials       46       46           
```


| [Impacted Files](https://codecov.io/gh/skovhus/jest-codemods/pull/337?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Kenneth+Skovhus) | Coverage Δ | |
|---|---|---|
| [src/transformers/chai-assert.ts](https://codecov.io/gh/skovhus/jest-codemods/pull/337/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Kenneth+Skovhus#diff-c3JjL3RyYW5zZm9ybWVycy9jaGFpLWFzc2VydC50cw==) | `99.21% <ø> (ø)` | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/skovhus/jest-codemods/pull/337?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Kenneth+Skovhus).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Kenneth+Skovhus)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/skovhus/jest-codemods/pull/337?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Kenneth+Skovhus). Last update [de5ab1b...57f17c2](https://codecov.io/gh/skovhus/jest-codemods/pull/337?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Kenneth+Skovhus). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Kenneth+Skovhus).


Patch:
diff --git a/src/transformers/chai-assert.ts b/src/transformers/chai-assert.ts
index 8f3522d..b6c5e15 100644
--- a/src/transformers/chai-assert.ts
+++ b/src/transformers/chai-assert.ts
@@ -50,6 +50,11 @@ const assertToExpectMapping = [
     expect: 'toEqual',
     includeNegative: 'notDeepEqual',
   },
+  {
+    assert: 'deepStrictEqual',
+    expect: 'toStrictEqual',
+    includeNegative: 'notDeepStrictEqual',
+  },
   {
     assert: 'isAbove',
     expect: 'toBeGreaterThan',


Test patch:
diff --git a/src/transformers/chai-assert.test.ts b/src/transformers/chai-assert.test.ts
index 4d92ae2..1304d9f 100644
--- a/src/transformers/chai-assert.test.ts
+++ b/src/transformers/chai-assert.test.ts
@@ -72,6 +72,8 @@ describe('Mapping Test', () => {
     ['assert.notStrictEqual(foo, bar, baz);', 'expect(foo).not.toBe(bar);'],
     ['assert.deepEqual(foo, bar, baz);', 'expect(foo).toEqual(bar);'],
     ['assert.notDeepEqual(foo, bar, baz);', 'expect(foo).not.toEqual(bar);'],
+    ['assert.deepStrictEqual(foo, bar, baz);', 'expect(foo).toStrictEqual(bar);'],
+    ['assert.notDeepStrictEqual(foo, bar, baz);', 'expect(foo).not.toStrictEqual(bar);'],
     ['assert.isAbove(foo, bar, baz);', 'expect(foo).toBeGreaterThan(bar);'],
     ['assert.isAtLeast(foo, bar, baz);', 'expect(foo).toBeGreaterThanOrEqual(bar);'],
     ['assert.isBelow(foo, bar, baz);', 'expect(foo).toBeLessThan(bar);'],