{"id":21307402,"url":"https://github.com/jdegand/testing-nested","last_synced_at":"2026-05-10T00:44:03.894Z","repository":{"id":233468765,"uuid":"690238685","full_name":"jdegand/testing-nested","owner":"jdegand","description":"Angular Challenges #18 Nested Comp Testing","archived":false,"fork":false,"pushed_at":"2023-09-11T20:06:00.000Z","size":154,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-22T09:12:43.946Z","etag":null,"topics":["angular","angular-challenges","cypress","jest","testing-library"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jdegand.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"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":"2023-09-11T20:04:00.000Z","updated_at":"2023-09-13T01:13:58.000Z","dependencies_parsed_at":null,"dependency_job_id":"154e2f58-94c7-4afe-b8d7-9602ecfdb4f4","html_url":"https://github.com/jdegand/testing-nested","commit_stats":null,"previous_names":["jdegand/testing-nested"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdegand%2Ftesting-nested","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdegand%2Ftesting-nested/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdegand%2Ftesting-nested/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdegand%2Ftesting-nested/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jdegand","download_url":"https://codeload.github.com/jdegand/testing-nested/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243784103,"owners_count":20347409,"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":["angular","angular-challenges","cypress","jest","testing-library"],"created_at":"2024-11-21T16:31:46.842Z","updated_at":"2026-05-10T00:44:03.862Z","avatar_url":"https://github.com/jdegand.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Testing Nested\n\n[Angular Challenges](https://github.com/tomalaforge/angular-challenges) #18 Nested Comp Testing\n\n## Built With\n\n- [Angular](https://angular.io)\n- [Angular CLI](https://github.com/angular/angular-cli) version 16.2.0.\n- [Testing Library Angular](https://testing-library.com/docs/angular-testing-library/intro)\n- [Jest](https://jestjs.io)\n- [Cypress](https://www.cypress.io)\n\n## Directions\n\nWe have a small application that sends a title to a fake backend when you type inside a input. If the title is correctly typed, the request is sent otherwise you get a nice error and the request is not sent.\n\n## Thoughts\n\n- The ChildComponent is really the parent component of many other components.  To test nested components, you primarily the test the nested component's functionality in its' parent component.\n- I looked at different ways of mocking the HttpService.  Check [useful resources](#useful-resources).\n- My solution is basically matches this [Angular Testing Library Component Provider example](https://github.com/testing-library/angular-testing-library/blob/9f9e8c385142218b1cc4439b050f8603780bfe7d/src/app/examples/05-component-provider.spec.ts).\n- Looking at the solution, it could possibly be outdated.  \n- createMockWithValues seems to be a newer method - search results for it are limited.  \n- Code coverage is not 100% when you just test that the method has been called.  \n- I tested Thomas' solution and his code coverage matched mine.  \n- Is it a bad practice to use toHaveBeenCalledTimes(0) ?\n\n## How to Use\n\n```bash \n\ngit clone https://github.com/jdegand/testing-nested.git\n\n# cd into the directory\nnpm install\n\n# Jest \n\nnpm test\n\n# Jest with Coverage\n\nnpm run test:coverage\n\n# Cypress\n\nnpm run cypress:open\n```\n\n## Useful Resources\n\n- [Github](https://github.com/testing-library/angular-testing-library/blob/9f9e8c385142218b1cc4439b050f8603780bfe7d/src/app/examples/05-component-provider.spec.ts) - angular testing library example with component provider\n- [snyk](https://snyk.io/advisor/npm-package/@testing-library/angular/functions/@testing-library%2Fangular%2Fjest-utils.createMock) - jest utils createMock\n- [blog](https://openvalue.blog/posts/2022/11/28/angular_jest_testing_library/) - angular jest testing library\n- [Github](https://github.com/RamzanTum/q-and-a) - source code of the blog example above\n- [Stack Overflow](https://stackoverflow.com/questions/53898085/check-if-an-error-has-been-written-to-the-console) - check if an error has been written to the console\n- [Cypress Docs](https://docs.cypress.io/faq/questions/using-cypress-faq#How-do-I-spy-on-consolelog) - how do I spy on console.log?\n- [YouTube](https://www.youtube.com/watch?v=ZslHKPtwIhA) - Spying On The Console Log Method","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjdegand%2Ftesting-nested","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjdegand%2Ftesting-nested","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjdegand%2Ftesting-nested/lists"}