{"id":15504214,"url":"https://github.com/kentcdodds/js-mocking-fundamentals","last_synced_at":"2025-04-04T19:14:16.436Z","repository":{"id":43466119,"uuid":"137975012","full_name":"kentcdodds/js-mocking-fundamentals","owner":"kentcdodds","description":"JavaScript Mocking Fundamentals on TestingJavaScript.com","archived":false,"fork":false,"pushed_at":"2024-02-01T15:49:05.000Z","size":176,"stargazers_count":306,"open_issues_count":0,"forks_count":286,"subscribers_count":12,"default_branch":"main","last_synced_at":"2024-10-19T18:25:30.189Z","etag":null,"topics":["kcd-edu","mocking","testing","testingjavascript"],"latest_commit_sha":null,"homepage":"https://testingjavascript.com/courses/javascript-mocking-fundamentals","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kentcdodds.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-06-20T03:23:36.000Z","updated_at":"2024-10-01T14:00:05.000Z","dependencies_parsed_at":"2024-10-31T02:04:13.548Z","dependency_job_id":null,"html_url":"https://github.com/kentcdodds/js-mocking-fundamentals","commit_stats":{"total_commits":19,"total_committers":5,"mean_commits":3.8,"dds":0.5263157894736843,"last_synced_commit":"c1d7c9bf275c0d55e413264d5eb602f5516ff4ae"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kentcdodds%2Fjs-mocking-fundamentals","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kentcdodds%2Fjs-mocking-fundamentals/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kentcdodds%2Fjs-mocking-fundamentals/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kentcdodds%2Fjs-mocking-fundamentals/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kentcdodds","download_url":"https://codeload.github.com/kentcdodds/js-mocking-fundamentals/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247234923,"owners_count":20905854,"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":["kcd-edu","mocking","testing","testingjavascript"],"created_at":"2024-10-02T09:16:40.254Z","updated_at":"2025-04-04T19:14:16.411Z","avatar_url":"https://github.com/kentcdodds.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003e\n  \u003ca href=\"https://testingjavascript.com/courses/javascript-mocking-fundamentals\"\u003eJavaScript Mocking Fundamentals\u003c/a\u003e\n\u003c/h1\u003e\n\n\u003cdiv align=\"center\"\u003e\n  \u003ch2\u003e\u003ca href=\"https://testingjavascript.com\"\u003eTestingJavaScript.com\u003c/a\u003e\u003c/h2\u003e\n  \u003ca href=\"https://testingjavascript.com\"\u003e\n    \u003cimg\n      width=\"500\"\n      alt=\"Learn the smart, efficient way to test any JavaScript application.\"\n      src=\"https://kentcdodds.com/images/testingjavascript-promo/tjs-4.jpg\"\n    /\u003e\n  \u003c/a\u003e\n\u003c/div\u003e\n\n\u003chr /\u003e\n\n\u003cp align=\"center\" style=\"font-size: 1.2rem;\"\u003e\n  Learn how mocking in JavaScript tests works by implementing them from scratch!\n\u003c/p\u003e\n\n\u003chr /\u003e\n\nIn this material, we have a set of `no-framework` tests that correspond to a set\nof jest tests (in the `__tests__` directory). The idea is that (with the\nexception of the first test), you look at the jest version first, then see how\nthat would be implemented without a testing framework.\n\nOrder of material:\n\n1.  `monkey-patching.js` (no jest version)\n2.  `mock-fn.js`\n3.  `spy.js`\n4.  `inline-module-mock.js`\n5.  `external-mock-module.js`\n\nThe files are intended to test the `thumb-war.js` module and mock the `utils`\nmodule.\n\nTo run the tests, run `npx jest`. To start watch mode run `npx jest --watch`\n\n## Custom jest runner.\n\nYou can definitely run the `no-framework` files just using `node` (like this:\n`node src/no-framework/monkey-patching.js`), but in an effort to make running\nthese easier, I created a custom jest runner that uses jest to run the files,\nbut allow them to be run without the jest testing framework. It's really cool.\nIt uses [`create-jest-runner`](https://www.npmjs.com/package/create-jest-runner)\nand should probably be published eventually.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkentcdodds%2Fjs-mocking-fundamentals","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkentcdodds%2Fjs-mocking-fundamentals","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkentcdodds%2Fjs-mocking-fundamentals/lists"}