{"id":13570460,"url":"https://github.com/briebug/jest-schematic","last_synced_at":"2025-04-12T15:36:47.300Z","repository":{"id":34648830,"uuid":"148957177","full_name":"briebug/jest-schematic","owner":"briebug","description":"Angular schematic for adding Jest and the required files to an Angular CLI project","archived":false,"fork":false,"pushed_at":"2023-07-12T11:09:48.000Z","size":3623,"stargazers_count":319,"open_issues_count":36,"forks_count":39,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-03-26T10:18:23.032Z","etag":null,"topics":["angular","jest","jest-schematic","schematic"],"latest_commit_sha":null,"homepage":"","language":"HTML","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/briebug.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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-09-16T02:43:29.000Z","updated_at":"2024-06-07T19:07:59.797Z","dependencies_parsed_at":"2024-06-07T19:19:45.868Z","dependency_job_id":null,"html_url":"https://github.com/briebug/jest-schematic","commit_stats":{"total_commits":125,"total_committers":10,"mean_commits":12.5,"dds":0.12,"last_synced_commit":"9b95c78b6937b8692ca17e04eaae436f37ddadf0"},"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/briebug%2Fjest-schematic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/briebug%2Fjest-schematic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/briebug%2Fjest-schematic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/briebug%2Fjest-schematic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/briebug","download_url":"https://codeload.github.com/briebug/jest-schematic/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248590419,"owners_count":21129813,"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","jest","jest-schematic","schematic"],"created_at":"2024-08-01T14:00:52.570Z","updated_at":"2025-04-12T15:36:47.278Z","avatar_url":"https://github.com/briebug.png","language":"HTML","readme":"# Jest Angular Schematic\n\nThis schematic will configure Angular to execute unit tests with Jest for single projects or workspaces.\n\n[![npm (scoped)](https://img.shields.io/npm/v/@briebug/jest-schematic.svg)](https://www.npmjs.com/package/@briebug/jest-schematic)\n\n## Usage 🚀\n\n```shell\nng add @briebug/jest-schematic\n```\n\n- install [Jest](https://facebook.github.io/jest/), types and a [builder](https://github.com/just-jeb/angular-builders/tree/master/packages/jest)\n- add Jest configuration files\n- remove Karma \u0026 Jasmine along with their configuration files\n\n### Optionally: install globally\n\n```shell\nnpm install -g @briebug/jest-schematic\n```\n\nThen in an Angular CLI project run\n\n```shell\nng g @briebug/jest-schematic:add\n```\n\n![jest-schematic-demo-500](docs/jest-schematic-demo-500.gif)\n\n## Issues 🧐\n\nIf you're experiencing issues when trying to run your tests with Jest, please view the documentation for the [builder](https://github.com/just-jeb/angular-builders/tree/master/packages/jest) which uses [jest-preset-angular](https://github.com/thymikee/jest-preset-angular#troubleshooting).\n\nA common issues involves library dependencies. For example if your app depends on `NgRx` you'll need to tell Jest to compile the sources [explicitly](https://github.com/thymikee/jest-preset-angular#adjust-your-transformignorepatterns-whitelist) by appending it to the `transformIgnorePatterns` property in the `jest.config.js` file.\n\n```js\nmodule.exports = {\n  transformIgnorePatterns: ['node_modules/(?!(jest-test|@ngrx))'],\n};\n```\n\n## Jest issues\n\nIssues related to jest, ts-jest, or test execution may be related the installed version of jest and jest-preset-angular. The schematic may install a version of jest other than latest in an attempt to configure package versions that work together correctly. If you experience issues with your tests after running the schematic related to the aforementioned packages, please review the package versions and adjust them as necessary.\n\nIssues with this schematic can be filed [here](https://github.com/briebug/jest-schematic/issues/new/choose).\n\n## Learning Resources 📚\n\n- [Unit Testing Angular With Jest](https://medium.com/@ole.ersoy/unit-testing-angular-with-jest-b65888ff33f6)\n\n## Development 🛠\n\n### Getting started\n\nClone or fork the repo and install the dependencies with Yarn\n\n```shell\nyarn\n```\n\n### Test schematic changes against a sandbox app\n\nWhen running locally, schematic changes will be applied to a test app in the `/sandboxes` directory. `/sandboxes` contain a single app repo and a workspace repo with an application and library.\n\nRun the following when a schematic change is made to test:\n\n```bash\n// runs against /sandboxes/single-app\nyarn test single\n\n// runs against /sandboxes/workspace\nyarn test workspace\n```\n\n⚠ **Be careful not to check in changes to the sandbox directory unless necessary.** ⚠\n\n### Reset sandboxes to their version controlled state\n\nThis will reset the sandboxes to their `HEAD` commit and remove un-tracked files.\n\n```shell\nyarn reset\n```\n\n### Test schematics against a local project\n\n- run `yarn build` to compile the schematic in watch mode\n- open another shell, cd into the local repo you want to run the schematic against, and run `yarn link @briebug/jest-schematic`. This assumes you've run `yarn link` in this repo on your machine.\n  - this will symlink the projects so that the Jest schematic command runs from you're local filesystem\n- in the local repo you want to run the schematic against, run `ng g @briebug/jest-schematic:add`\n\n### Update sandboxes\n\nWhen a new version of Angular is released, update all the sandbox apps and libs to the latest version.\n\n_replace `15` with the latest version of Angular_\n\n```shell\ncd sandbox\n\nrm single-app\n\nnpx @angular/cli@15 new single-app --routing --style=css --skip-git --package-manager=yarn\n\nrm workspace\n\nnpx @angular/cli@15 new workspace --create-application=false --skip-git --package-manager=yarn\n\ncd workspace\n\nng g app app-one --routing --style=css --skip-git\n\nng g lib lib-one\n```\n\n### Dev tips\n\nFor faster developing, find and comment out the following line to avoid npm installing dependencies\n\n```ts\ncontext.addTask(new NodePackageInstallTask());\n```\n","funding_links":[],"categories":["HTML"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbriebug%2Fjest-schematic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbriebug%2Fjest-schematic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbriebug%2Fjest-schematic/lists"}