{"id":15503902,"url":"https://github.com/kentcdodds/testing-node-apps","last_synced_at":"2025-04-04T13:11:05.431Z","repository":{"id":37451238,"uuid":"190789791","full_name":"kentcdodds/testing-node-apps","owner":"kentcdodds","description":"Test Node.js Backends on TestingJavaScript.com","archived":false,"fork":false,"pushed_at":"2024-08-13T08:51:46.000Z","size":744,"stargazers_count":388,"open_issues_count":9,"forks_count":204,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-03-28T12:05:27.432Z","etag":null,"topics":["kcd-edu","node","testing","testingjavascript"],"latest_commit_sha":null,"homepage":"https://testingjavascript.com/courses/test-node-js-backends","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":"2019-06-07T18:19:17.000Z","updated_at":"2025-03-21T01:03:45.000Z","dependencies_parsed_at":"2024-10-29T17:37:15.606Z","dependency_job_id":null,"html_url":"https://github.com/kentcdodds/testing-node-apps","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/kentcdodds%2Ftesting-node-apps","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kentcdodds%2Ftesting-node-apps/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kentcdodds%2Ftesting-node-apps/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kentcdodds%2Ftesting-node-apps/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kentcdodds","download_url":"https://codeload.github.com/kentcdodds/testing-node-apps/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247181754,"owners_count":20897373,"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","node","testing","testingjavascript"],"created_at":"2024-10-02T09:15:10.144Z","updated_at":"2025-04-04T13:11:05.416Z","avatar_url":"https://github.com/kentcdodds.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003e\n  \u003ca href=\"https://testingjavascript.com/courses/test-node-js-backends\"\u003eTesting Node.js Backends\u003c/a\u003e\n\u003c/h1\u003e\n\n👋 hi there! My name is [Kent C. Dodds](https://kentcdodds.com)! This is a\nworkshop repo to teach you how to test your Node.js Apps!\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[![Build Status][build-badge]][build]\n[![Code Coverage][coverage-badge]][coverage]\n[![GPL 3.0 License][license-badge]][license]\n[![All Contributors][all-contributors-badge]](#contributors)\n[![PRs Welcome][prs-badge]][prs] [![Code of Conduct][coc-badge]][coc]\n\n## Prerequisites\n\n- Have fundamental understanding and experience with automated testing and\n  tools. (Additional learning material:\n  [But really, what is a JavaScript test?](https://kentcdodds.com/blog/but-really-what-is-a-javascript-test)\n  and\n  [But really, what is a JavaScript mock?](https://kentcdodds.com/blog/but-really-what-is-a-javascript-mock))\n- Have experience with modern JavaScript APIs and features.\n\n## System Requirements\n\n- [git][git] v2 or greater\n- [NodeJS][node] v12 or greater\n- [yarn][yarn] v1 or greater (or [npm][npm] v6 or greater)\n\nAll of these must be available in your `PATH`. To verify things are set up\nproperly, you can run this:\n\n```shell\ngit --version\nnode --version\nyarn --version # or npm --version\n```\n\nIf you have trouble with any of these, learn more about the PATH environment\nvariable and how to fix it here for [windows][win-path] or\n[mac/linux][mac-path].\n\n## Setup\n\n\u003e If you want to commit and push your work as you go, you'll want to\n\u003e [fork](https://docs.github.com/en/free-pro-team@latest/github/getting-started-with-github/fork-a-repo)\n\u003e first and then clone your fork rather than this repo directly.\n\nAfter you've made sure to have the correct things (and versions) installed, you\nshould be able to just run a few commands to get set up:\n\n```\ngit clone https://github.com/kentcdodds/testing-node-apps.git\ncd testing-node-apps\nnode setup\n```\n\nThis may take a few minutes. **It will ask you for your email.** This is\noptional and just automatically adds your email to the links in the project to\nmake filling out some forms easier.\n\nIf you get any errors, please read through them and see if you can find out what\nthe problem is. If you can't work it out on your own then please [file an\nissue][issue] and provide _all_ the output from the commands you ran (even if\nit's a lot).\n\nIf you can't get the setup script to work, then just make sure you have the\nright versions of the requirements listed above, and run the following commands:\n\n```\nnpm install\nnpm run validate\n```\n\nIt's recommended you run everything locally in the same environment you work in\nevery day, but if you're having issues getting things set up, you can also set\nthis up using [GitHub Codespaces](https://github.com/features/codespaces)\n([video demo](https://www.youtube.com/watch?v=gCoVJm3hGk4)) or\n[Codesandbox](https://codesandbox.io/s/github/kentcdodds/testing-node-apps).\n\n## App Intro\n\n### App Demo\n\nThis is the backend for [Bookshelf](https://bookshelf.lol). I recommend you play\naround with it a little bit to get an idea of the kind of data we're dealing\nwith here.\n\n### Data Model\n\n- User\n\n  - id: string\n  - username: string\n\n- List Item\n\n  - id: string\n  - bookId: string\n  - ownerId: string\n  - rating: number (-1 is no rating, otherwise it's 1-5)\n  - notes: string\n  - startDate: number (`Date.now()`)\n  - finishDate: number (`Date.now()`)\n\n\u003e For convenience, our we return a `book` object on each list item which is the\n\u003e book it's associated to. You're welcome frontend folks!\n\n\u003e /me wishes we could use GraphQL\n\n- Book\n\n  - id: string\n  - title: string\n  - author: string\n  - coverImageUrl: string\n  - pageCount: number\n  - publisher: string\n  - synopsis: string\n\n## Running the tests\n\n```shell\nnpm test\n```\n\nThis will start [Jest](https://jestjs.io/) in watch mode. Read the output and\nplay around with it. You'll be working in the `.exercise` files.\n\n### Exercises\n\n- `src/**/__tests__/[title].md`: Background, Exercise Instructions, Extra Credit\n- `src/**/__tests__/[title].exercise.js`: Exercise with Emoji helpers\n- `src/**/__tests__/[title].final.js`: Final version\n- `src/**/__tests__/[title].final.extra-#.js`: Final version of extra credit\n- `src/**/[title].js`: The source file that you'll be testing\n\nThe purpose of the exercise is **not** for you to work through all the material.\nIt's intended to get your brain thinking about the right questions to ask me as\n_I_ walk through the material.\n\nHere's the order of exercises we'll be doing as well as where you can find the\nmarkdown file associated with each.\n\n1.  🏋 Testing Pure Functions: `src/utils/__tests__/auth.md`\n2.  🏋 Testing Middleware: `src/utils/__tests__/error-middleware.md`\n3.  🏋 Testing Controllers: `src/routes/__tests__/list-items-controller.md`\n4.  🏋 Testing Authentication API Routes: `src/__tests__/auth.md`\n5.  🏋 Testing CRUD API Routes: `src/__tests__/list-items.md`\n\n### Helpful Emoji 🐨 💪 🏁 💰 💯 🦉 📜 💣 👨‍💼 🚨\n\nEach exercise has comments in it to help you get through the exercise. These fun\nemoji characters are here to help you.\n\n- **Kody the Koala** 🐨 will tell you when there's something specific you should\n  do\n- **Matthew the Muscle** 💪 will indicate what you're working with an exercise\n- **Chuck the Checkered Flag** 🏁 will indicate that you're working with a final\n  version\n- **Marty the Money Bag** 💰 will give you specific tips (and sometimes code)\n  along the way\n- **Hannah the Hundred** 💯 will give you extra challenges you can do if you\n  finish the exercises early.\n- **Olivia the Owl** 🦉 will give you useful tidbits/best practice notes and a\n  link for elaboration and feedback.\n- **Dominic the Document** 📜 will give you links to useful documentation\n- **Berry the Bomb** 💣 will be hanging around anywhere you need to blow stuff\n  up (delete code)\n- **Peter the Product Manager** 👨‍💼 helps us know what our users want\n- **Alfred the Alert** 🚨 will occasionally show up in the test failures with\n  potential explanations for why the tests are failing.\n\n## Troubleshooting\n\n\u003cdetails\u003e\n\n\u003csummary\u003e\"node setup\" not working\u003c/summary\u003e\n\nIf you're confident that your system meets the system requirements above, then\nyou can skip the system validation and manually setup the project:\n\n```\nnpm install\nnpm run validate\n```\n\nIf those scripts fail, please try to work out what went wrong by the error\nmessage you get. If you still can't work it out, feel free to [open an\nissue][issue] with _all_ the output from that script. I will try to help if I\ncan.\n\n\u003c/details\u003e\n\n## Contributors\n\nThanks goes to these wonderful people\n([emoji key](https://github.com/all-contributors/all-contributors#emoji-key)):\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --\u003e\n\u003c!-- prettier-ignore-start --\u003e\n\u003c!-- markdownlint-disable --\u003e\n\u003ctable\u003e\n  \u003ctr\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://kentcdodds.com\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/1500684?v=3\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eKent C. Dodds\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/kentcdodds/testing-node-apps/commits?author=kentcdodds\" title=\"Code\"\u003e💻\u003c/a\u003e \u003ca href=\"https://github.com/kentcdodds/testing-node-apps/commits?author=kentcdodds\" title=\"Documentation\"\u003e📖\u003c/a\u003e \u003ca href=\"#infra-kentcdodds\" title=\"Infrastructure (Hosting, Build-Tools, etc)\"\u003e🚇\u003c/a\u003e \u003ca href=\"https://github.com/kentcdodds/testing-node-apps/commits?author=kentcdodds\" title=\"Tests\"\u003e⚠️\u003c/a\u003e\u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://stackshare.io/jdorfman/decisions\"\u003e\u003cimg src=\"https://avatars1.githubusercontent.com/u/398230?v=4\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eJustin Dorfman\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"#fundingFinding-jdorfman\" title=\"Funding Finding\"\u003e🔍\u003c/a\u003e\u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://www.andrewm.codes\"\u003e\u003cimg src=\"https://avatars1.githubusercontent.com/u/18423853?v=4\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eAndrew Mason\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/kentcdodds/testing-node-apps/commits?author=andrewmcodes\" title=\"Documentation\"\u003e📖\u003c/a\u003e\u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\n\u003c!-- markdownlint-enable --\u003e\n\u003c!-- prettier-ignore-end --\u003e\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:END --\u003e\n\nThis project follows the\n[all-contributors](https://github.com/all-contributors/all-contributors)\nspecification. Contributions of any kind welcome!\n\n## License\n\nThis material is available for private, non-commercial use under the\n[GPL version 3](http://www.gnu.org/licenses/gpl-3.0-standalone.html). If you\nwould like to use this material to conduct your own workshop, please contact me\nat me@kentcdodds.com\n\n## Workshop Feedback\n\nEach exercise has an Elaboration and Feedback link. Please fill that out after\nthe exercise and instruction.\n\nAt the end of the workshop, please go to this URL to give overall feedback.\nThank you! https://kcd.im/tna-ws-feedback\n\n\u003c!-- prettier-ignore-start --\u003e\n\n[npm]: https://www.npmjs.com/\n[node]: https://nodejs.org\n[git]: https://git-scm.com/\n[yarn]: https://yarnpkg.com/\n[build-badge]: https://img.shields.io/github/workflow/status/kentcdodds/testing-node-apps/validate/main?logo=github\u0026style=flat-square\n[build]: https://github.com/kentcdodds/testing-node-apps/actions?query=workflow%3Avalidate\n[license-badge]: https://img.shields.io/badge/license-GPL%203.0%20License-blue.svg?style=flat-square\n[license]: https://github.com/kentcdodds/testing-node-apps/blob/master/README.md#license\n[prs-badge]: https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square\n[prs]: http://makeapullrequest.com\n[coc-badge]: https://img.shields.io/badge/code%20of-conduct-ff69b4.svg?style=flat-square\n[coc]: https://github.com/kentcdodds/testing-node-apps/blob/master/CODE_OF_CONDUCT.md\n[github-watch-badge]: https://img.shields.io/github/watchers/kentcdodds/testing-node-apps.svg?style=social\n[github-watch]: https://github.com/kentcdodds/testing-node-apps/watchers\n[github-star-badge]: https://img.shields.io/github/stars/kentcdodds/testing-node-apps.svg?style=social\n[github-star]: https://github.com/kentcdodds/testing-node-apps/stargazers\n[twitter]: https://twitter.com/intent/tweet?text=Check%20out%20testing-node-apps%20by%20@kentcdodds%20https://github.com/kentcdodds/testing-node-apps%20%F0%9F%91%8D\n[twitter-badge]: https://img.shields.io/twitter/url/https/github.com/kentcdodds/testing-node-apps.svg?style=social\n[emojis]: https://github.com/all-contributors/all-contributors#emoji-key\n[all-contributors]: https://github.com/all-contributors/all-contributors\n[all-contributors-badge]: https://img.shields.io/github/all-contributors/kentcdodds/testing-node-apps?color=orange\u0026style=flat-square\n[win-path]: https://www.howtogeek.com/118594/how-to-edit-your-system-path-for-easy-command-line-access/\n[mac-path]: http://stackoverflow.com/a/24322978/971592\n[issue]: https://github.com/kentcdodds/testing-node-apps/issues/new\n[win-build-badge]: https://img.shields.io/appveyor/ci/kentcdodds/testing-node-apps.svg?style=flat-square\u0026logo=appveyor\n[win-build]: https://ci.appveyor.com/project/kentcdodds/testing-node-apps\n[coverage-badge]: https://img.shields.io/codecov/c/github/kentcdodds/testing-node-apps.svg?style=flat-square\n[coverage]: https://codecov.io/github/kentcdodds/testing-node-apps\n[watchman]: https://facebook.github.io/watchman/docs/install.html\n\n\u003c!-- prettier-ignore-end --\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkentcdodds%2Ftesting-node-apps","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkentcdodds%2Ftesting-node-apps","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkentcdodds%2Ftesting-node-apps/lists"}