{"id":17167437,"url":"https://github.com/liuuy/angular-test-using-jest","last_synced_at":"2026-03-07T11:01:23.869Z","repository":{"id":133453277,"uuid":"128026151","full_name":"LiuuY/angular-test-using-jest","owner":"LiuuY","description":" Demonstrate how to use Jest to test Angular project","archived":false,"fork":false,"pushed_at":"2019-12-26T12:12:35.000Z","size":355,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-13T15:42:09.060Z","etag":null,"topics":["angular","jest","snapshot-testing","testing","ui-testing"],"latest_commit_sha":null,"homepage":null,"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/LiuuY.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":"2018-04-04T07:41:48.000Z","updated_at":"2019-12-31T01:43:28.000Z","dependencies_parsed_at":"2023-04-05T15:02:05.645Z","dependency_job_id":null,"html_url":"https://github.com/LiuuY/angular-test-using-jest","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/LiuuY/angular-test-using-jest","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LiuuY%2Fangular-test-using-jest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LiuuY%2Fangular-test-using-jest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LiuuY%2Fangular-test-using-jest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LiuuY%2Fangular-test-using-jest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LiuuY","download_url":"https://codeload.github.com/LiuuY/angular-test-using-jest/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LiuuY%2Fangular-test-using-jest/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30212103,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-07T09:02:10.694Z","status":"ssl_error","status_checked_at":"2026-03-07T09:02:08.429Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["angular","jest","snapshot-testing","testing","ui-testing"],"created_at":"2024-10-14T23:08:45.532Z","updated_at":"2026-03-07T11:01:23.818Z","avatar_url":"https://github.com/LiuuY.png","language":"TypeScript","readme":"# 使用 Jest 测试 Angular 组件\n\nAngular 版本：8.2.0，本项目由 Angular CLI 生成，使用 Jest 替换了 Jasmine\n\n## 背景\n\nJest 在效率、易用性上都胜于 Jasmine 且完全兼容已有的 Jasmine 语法 （虽然 Angular 官方依旧推荐 Jasmine），\n\n尤其是 Jest 的 [Snapshot Testing](https://jestjs.io/docs/en/snapshot-testing)，很适合轻量级的 UI 测试。\n\n~~也适合提高测试覆盖率 😆~~。\n\n例如修改了 template 后运行测试，就会有相应的提示\n\n![](https://raw.githubusercontent.com/LiuuY/angular-test-using-jest/master/screenshots/snapshot.png)\n\n## 使用方法\n\nAngular 集成 Jest 一般都会使用 [jest-present-angular](https://github.com/thymikee/jest-preset-angular)。\n\n但是这个文档忽略了介绍几个重要的配置，导致不能很简单的集成。\n\n我使用 Angular CLI 生成了一个标准 Angular 工程，在此基础上直接集成了 Jest。\n\n大家可以直接对照，详见 [diff.patch](https://github.com/LiuuY/angular-test-using-jest/blob/master/diff.patch)。\n\n## 其他 😏\n[State of JS 关于 Testing 框架流行度调查](https://2019.stateofjs.com/testing/)\n![](https://raw.githubusercontent.com/LiuuY/angular-test-using-jest/master/screenshots/trend.png)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fliuuy%2Fangular-test-using-jest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fliuuy%2Fangular-test-using-jest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fliuuy%2Fangular-test-using-jest/lists"}