{"id":36502968,"url":"https://github.com/pauldcomanici/jest-serializer-functions","last_synced_at":"2026-01-12T02:25:55.236Z","repository":{"id":38980440,"uuid":"158282710","full_name":"pauldcomanici/jest-serializer-functions","owner":"pauldcomanici","description":"Jest serializer for functions","archived":false,"fork":false,"pushed_at":"2023-01-03T15:21:43.000Z","size":1301,"stargazers_count":0,"open_issues_count":45,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-08-09T08:56:28.742Z","etag":null,"topics":["jest","jest-serializer","jest-serializer-functions","unit-testing"],"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/pauldcomanici.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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-11-19T20:01:12.000Z","updated_at":"2019-08-27T14:23:51.000Z","dependencies_parsed_at":"2023-02-01T06:55:12.303Z","dependency_job_id":null,"html_url":"https://github.com/pauldcomanici/jest-serializer-functions","commit_stats":null,"previous_names":["darkyndy/jest-serializer-functions"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/pauldcomanici/jest-serializer-functions","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pauldcomanici%2Fjest-serializer-functions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pauldcomanici%2Fjest-serializer-functions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pauldcomanici%2Fjest-serializer-functions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pauldcomanici%2Fjest-serializer-functions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pauldcomanici","download_url":"https://codeload.github.com/pauldcomanici/jest-serializer-functions/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pauldcomanici%2Fjest-serializer-functions/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28332387,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-12T00:36:25.062Z","status":"online","status_checked_at":"2026-01-12T02:00:08.677Z","response_time":98,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["jest","jest-serializer","jest-serializer-functions","unit-testing"],"created_at":"2026-01-12T02:25:55.169Z","updated_at":"2026-01-12T02:25:55.225Z","avatar_url":"https://github.com/pauldcomanici.png","language":"JavaScript","funding_links":["https://www.patreon.com/paul_comanici","https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=T645WN5RWR6WS\u0026source=url"],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://travis-ci.org/darkyndy/jest-serializer-functions\"\u003e\n    \u003cimg\n      alt=\"Travis Status\"\n      src=\"https://travis-ci.org/darkyndy/jest-serializer-functions.svg?branch=master\"\n    /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://codecov.io/gh/darkyndy/jest-serializer-functions\"\u003e\n    \u003cimg\n      alt=\"Coverage Status\"\n      src=\"https://codecov.io/gh/darkyndy/jest-serializer-functions/branch/master/graph/badge.svg\"\n    /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://snyk.io/test/github/darkyndy/jest-serializer-functions?targetFile=package.json\"\u003e\n    \u003cimg\n      alt=\"Known Vulnerabilities\"\n      src=\"https://snyk.io/test/github/darkyndy/jest-serializer-functions/badge.svg?targetFile=package.json\"\n      data-canonical-src=\"https://snyk.io/test/github/darkyndy/jest-serializer-functions?targetFile=package.json\"\n      style=\"max-width:100%;\"\n    /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://david-dm.org/darkyndy/jest-serializer-functions\"\u003e\n    \u003cimg\n      alt=\"dependencies status\"\n      src=\"https://david-dm.org/darkyndy/jest-serializer-functions/status.svg\"\n    /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://david-dm.org/darkyndy/jest-serializer-functions?type=dev\"\u003e\n    \u003cimg\n      alt=\"devDependencies status\"\n      src=\"https://david-dm.org/darkyndy/jest-serializer-functions/dev-status.svg\"\n    /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://www.npmjs.com/package/jest-serializer-functions\"\u003e\n    \u003cimg\n      alt=\"npm Downloads\"\n      src=\"https://img.shields.io/npm/dm/jest-serializer-functions.svg?maxAge=57600\"\n    /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/darkyndy/jest-serializer-functions/blob/master/LICENSE\"\u003e\n    \u003cimg\n      alt=\"MIT License\"\n      src=\"https://img.shields.io/npm/l/jest-serializer-functions.svg\"\n    /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://app.fossa.io/projects/git%2Bgithub.com%2Fdarkyndy%2Fjest-serializer-functions?ref=badge_shield\"\u003e\n    \u003cimg\n      alt=\"FOSSA Status\"\n      src=\"https://app.fossa.io/api/projects/git%2Bgithub.com%2Fdarkyndy%2Fjest-serializer-functions.svg?type=shield\"\n    /\u003e\n  \u003c/a\u003e\n  \u003cbr/\u003e\n  \u003ca href=\"https://www.patreon.com/paul_comanici\"\u003e\n    \u003cimg\n      alt=\"support the author\"\n      src=\"https://img.shields.io/badge/patreon-support%20the%20author-blue.svg\"\n    /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=T645WN5RWR6WS\u0026source=url\"\u003e\n    \u003cimg\n      alt=\"donate\"\n      src=\"https://img.shields.io/badge/paypal-donate-blue.svg\"\n    /\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n\n# jest-serializer-functions\nJest snapshot serializer for functions. Read more about [snapshotSerializers](https://jestjs.io/docs/en/configuration.html#snapshotserializers-array-string)\n\n## Background\nWhenever you are using Jest for snapshot you may notice that functions will appear in snapshots in different ways.\nIf the function is mocked you will see it as:\n* `[Function]`\n  * when the function is not mocked with Jest\n  * when you have React component that has a function inside JSX (consumers) \n* `[MockFunction]`\n  * when the function is mocked with jest, usually implementation is: `myFn = jest.fn()`\n* `[MockFunction \u003c\u003cfunction-name\u003e\u003e]`\n  * where `\u003c\u003cfunction-name\u003e\u003e` is the name of the function\n* ```[MockFunction] {calls: [] results: []}```\n  * when the mocked function was called previously\n  \n### How it works\nThis serializer will help you have a more consistent way of viewing functions as every time will return `[Function]` as the base.\n\nIf the function has a name it will serialize it as `[Function] \u003c\u003cfunction-name\u003e\u003e`.\nAs the part where the function is mocked or not just adds noise to the important part.\n\nNow the good part :astonished: is when you are using this serialiser\nwith (React)[https://www.npmjs.com/package/react] (and [enzyme](https://www.npmjs.com/package/enzyme))\nas it will improve what you can see in the snapshot. Take as example source code:\n```jsx\n\u003cContext.Consumer\u003e\n  {\n    (handler) =\u003e (\n      \u003cSubscriber\n        handler={handler\n      /\u003e\n    )\n  }\n\u003c/Context.Consumer\u003e\n```\nthis will result in a snapshot that will look like:\n```jsx\n\u003cContext.Consumer\u003e\n  [Function]\n\u003c/Context.Consumer\u003e\n```\nI would not say this is very helpful (if I change something from the function nothing will break in my snapshot).\nThis serializer will return:\n\n```jsx\n\u003cContext.Consumer\u003e\n  () =\u003e (\u003cSubscriber\n    handler={handler}\n  /\u003e)\n\u003c/Context.Consumer\u003e\n```\n\n## Installation\n```sh\nnpm install --save-dev jest-serializer-functions\n```\nOr if you are using [yarn](https://yarnpkg.com/en/)\n```sh\nyarn add --dev jest-serializer-functions\n```\n\n## Usage\n\n### Having jest config as json\n```json\n// jest.json\n{\n  ...\n  \"snapshotSerializers\": [\n    \"jest-serializer-functions\"\n  ],\n  ...\n}\n```\n\n### Having jest config as json inside package.json\n```json\n// package.json\n{\n  ...\n  \"jest\": {\n    ...\n    \"snapshotSerializers\": [\n      \"jest-serializer-functions\"\n    ],\n    ...\n  },\n  ...\n}\n```\n\n## Take into consideration\n\n\u003e Everything has pros \u0026 cons.\n\n### Pros\nThis serializer will help you with a better understanding of your functions and fail tests that until now passed when doing partial refactoring.\n\n### Cons\nThe time to execute your tests will increase (depending on how many snapshots you have like this).\n\nThe space used by snapshot will increase, as more data will be stored.\n\n## Contributing\n\nPull requests and issues are welcome :heart:.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpauldcomanici%2Fjest-serializer-functions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpauldcomanici%2Fjest-serializer-functions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpauldcomanici%2Fjest-serializer-functions/lists"}