{"id":13532429,"url":"https://github.com/devenbansod/jest-expect-codemod","last_synced_at":"2025-10-09T00:20:15.747Z","repository":{"id":34249704,"uuid":"124369781","full_name":"devenbansod/jest-expect-codemod","owner":"devenbansod","description":"CodeMods for migrating `chai.assert`, `chai.expect`, `assert` -based test assertions to jest's `expect` assertions","archived":false,"fork":false,"pushed_at":"2022-12-07T09:33:21.000Z","size":722,"stargazers_count":9,"open_issues_count":3,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-28T01:01:40.700Z","etag":null,"topics":["assert","chai","codemod","jest"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/devenbansod.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-03-08T09:38:05.000Z","updated_at":"2022-07-23T23:18:57.000Z","dependencies_parsed_at":"2023-01-15T05:40:07.303Z","dependency_job_id":null,"html_url":"https://github.com/devenbansod/jest-expect-codemod","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devenbansod%2Fjest-expect-codemod","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devenbansod%2Fjest-expect-codemod/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devenbansod%2Fjest-expect-codemod/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devenbansod%2Fjest-expect-codemod/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devenbansod","download_url":"https://codeload.github.com/devenbansod/jest-expect-codemod/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248877986,"owners_count":21176239,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["assert","chai","codemod","jest"],"created_at":"2024-08-01T07:01:10.902Z","updated_at":"2025-10-09T00:20:10.728Z","avatar_url":"https://github.com/devenbansod.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# jest-expect-codemod\nCodeMods for migrating `chai.assert`, `chai.expect`, `assert` -based test assertions to [jest's `expect`](https://facebook.github.io/jest/docs/en/expect.html) assertions\n\nThis repository contains a collection of codemod scripts for use with [JSCodeshift](https://github.com/facebook/jscodeshift).\n\n*Currently, we don't support migration of all the assertions provided by these libraries, but PRs to add them are welcome. :-)*\n\n\u003ca href=\"https://travis-ci.org/devenbansod/jest-expect-codemod\"\u003e\u003cimg alt=\"Travis Status\" src=\"https://travis-ci.org/devenbansod/jest-expect-codemod.svg?branch=master\"\u003e\u003c/a\u003e\n\n### Setup \u0026 Run\n\n```sh\ngit clone https://github.com/devenbansod/jest-expect-codemod.git\nyarn run shift -t transformations/\u003ccodemod-script\u003e \u003cfile/folder to be converted\u003e\n```\n\nUse the `-d` option for a dry-run and use `-p` to print the output for\ncomparison.\n\n### Included Scripts\n\n#### Migrate from [`assert`](https://nodejs.org/api/assert.html)\n\n```sh\nyarn run shift -t jest-expect-codemod/transforms/assert.js \u003cfile\u003e\n```\n\n#### Migrate from [`chai.assert`](https://chaijs.com/api/assert/)\n\n```sh\nyarn run shift -t jest-expect-codemod/transforms/chaiAssert.js \u003cfile\u003e\n```\n\n#### Migrate from [`chai.expect`](https://chaijs.com/api/bdd/)\n\n```sh\nyarn run shift -t jest-expect-codemod/transforms/chaiExpect.js \u003cfile\u003e\n```\n\n### Samples\n#### Migrate from [`assert`](https://nodejs.org/api/assert.html)\n\n##### Input\n```js\nmodule.exports = function() {\n  const a = 1;\n  assert.equal(a, 1);\n\n  const b = {\n    a: 2,\n  };\n  assert.deepEqual(b, {\n    a: 2,\n  });\n\n  const c = true;\n  assert.ok(c);\n\n  const d = 5;\n  assert.notEqual(d, 3);\n\n  assert.throws(() =\u003e {\n    throw new Error(\"Wrong value\");\n  }, /value/);\n\n  const e = 1;\n  assert.strictEqual(e, 1);\n};\n```\n\n##### Output\n```js\nmodule.exports = function() {\n  const a = 1;\n  expect(a).toBe(1);\n\n  const b = {\n    a: 2,\n  };\n  expect(b).toEqual({\n    a: 2,\n  });\n\n  const c = true;\n  expect(c).toBeTruthy();\n\n  const d = 5;\n  expect(d).not.toBe(3);\n\n  expect(() =\u003e {\n    throw new Error(\"Wrong value\");\n  }).toThrow(/value/);\n\n  const e = 1;\n  expect(e).toBe(1);\n};\n```\n\n#### Migrate from [`chai.assert`](https://chaijs.com/api/assert/)\n\n##### Input\n```js\nmodule.exports = function() {\n  const a = 1;\n  assert.equal(a, 1);\n  assert.notEqual(a, 3);\n\n  const b = {\n    a: 2,\n  };\n  assert.deepEqual(b, {\n    a: 2,\n  });\n  assert.notDeepEqual(b, {\n    c: 2,\n  });\n\n  const c = true;\n  assert.isNotOk(!c);\n  assert.isOk(c);\n\n  assert.isNotTrue(!c);\n  assert.isTrue(c);\n\n  assert.isNotFalse(!c);\n  assert.isNotFalse(c);\n\n  const d = 1;\n  assert.strictEqual(d, 1);\n  assert.notStrictEqual(d, 2);\n};\n```\n\n#### Migrate from [`chai.expect`](https://chaijs.com/api/bdd/)\n\n##### Input\n```js\nmodule.exports = function() {\n  const a = 1;\n  expect(a).to.equal(1);\n\n  const b = {\n    a: 2,\n  };\n  expect(b).to.eql({\n    a: 2,\n  });\n};\n```\n\n##### Output\n```js\nmodule.exports = function() {\n  const a = 1;\n  expect(a).toBe(1);\n\n  const b = {\n    a: 2,\n  };\n  expect(b).toEqual({\n    a: 2,\n  });\n};\n```\n\n### Motivation\nThis was initially written with a motivation to ease the migration the tests in [babel](https://github.com/babel/babel) to Jest Expect assertions (tracked at [#7476](https://github.com/babel/babel/issues/7476)).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevenbansod%2Fjest-expect-codemod","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevenbansod%2Fjest-expect-codemod","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevenbansod%2Fjest-expect-codemod/lists"}