{"id":16533430,"url":"https://github.com/mzgoddard/jest-webpack","last_synced_at":"2025-05-08T00:34:16.557Z","repository":{"id":57129037,"uuid":"93420487","full_name":"mzgoddard/jest-webpack","owner":"mzgoddard","description":"Use jest with webpack.","archived":false,"fork":false,"pushed_at":"2020-06-12T14:24:18.000Z","size":259,"stargazers_count":92,"open_issues_count":22,"forks_count":16,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-28T22:17:50.868Z","etag":null,"topics":["integrating-jest","jest","webpack","webpack-plugin"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/jest-webpack","language":"JavaScript","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/mzgoddard.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}},"created_at":"2017-06-05T15:48:01.000Z","updated_at":"2023-12-11T17:09:34.000Z","dependencies_parsed_at":"2022-09-06T00:12:01.377Z","dependency_job_id":null,"html_url":"https://github.com/mzgoddard/jest-webpack","commit_stats":null,"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mzgoddard%2Fjest-webpack","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mzgoddard%2Fjest-webpack/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mzgoddard%2Fjest-webpack/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mzgoddard%2Fjest-webpack/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mzgoddard","download_url":"https://codeload.github.com/mzgoddard/jest-webpack/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252978478,"owners_count":21834907,"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":["integrating-jest","jest","webpack","webpack-plugin"],"created_at":"2024-10-11T18:14:49.087Z","updated_at":"2025-05-08T00:34:16.540Z","avatar_url":"https://github.com/mzgoddard.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# jest-webpack\n\n[![Build Status](https://travis-ci.org/mzgoddard/jest-webpack.svg?branch=master)](https://travis-ci.org/mzgoddard/jest-webpack) [![Build status](https://ci.appveyor.com/api/projects/status/g4xvtyepm30hf48i/branch/master?svg=true)](https://ci.appveyor.com/project/mzgoddard/jest-webpack/branch/master)\n\nA helper tool and webpack plugin to integrate [`jest`](https://facebook.github.io/jest/) and [`webpack`](https://webpack.js.org/).\n\nAdd it to your project as a developer dependency. And run it like `webpack` or `webpack-dev-server` from the command line or as a `package.json` script.\n\n#### Install\n\n```sh\nnpm install --save-dev jest-webpack\n```\n\nor with `yarn`\n\n```sh\nyarn add -D jest-webpack\n```\n\n#### Update package.json\n\nAdd it as a `package.json` script\n\n```json\n{\n  \"name\": \"my-package\",\n  \"scripts\": {\n    \"test\": \"jest-webpack\"\n```\n\n#### Run it\n\n```sh\nnpm test\n```\n\nRun it with jest options\n\n```sh\nnpm test -- --testPathPattern test-just-this-file\n```\n\n## Status\n\n`jest-webpack` currently works with a lot of jest options out of the bag since there is no special handling needed and they can just be passed to jest by the tool. You can see what is so far specifically tested so far in https://github.com/mzgoddard/jest-webpack/issues/3.\n\n## How it works?\n\n`jest-webpack` uses a webpack plugin to add related plugins that are responsible for 4 operations.\n\n1. The `TestEntriesPlugin` finds test files that jest will operate on and creates entry chunks for them.\n2. The `EntryReferencePlugin` creates additional entries for any other files that are depended on by those test files. These entries return objects pointing to the various transformations of that file. If a css file is depended on by both `css-loader` and `css-loader/locals` for example, both of the outputs of those loaders will be in the same file. Files then depending on those outputs reference the entry chunk and use the exported member for their needed version of the original file.\n3. The `EmitChangedAssetsPlugin` removes entry chunks that already exist in the destination folder. It also includes package.json for the tested project.\n4. The `RunJestWhenDonePlugin` runs jest when webpack is done. It runs jest from the destination folder so jest uses the webpack transformed files. This lets jest determine what files changed and which runs to test again instead of testing all the files again.\n\nThis way of integrating jest and webpack is fairly transparent, requiring little modification to a webpack project. Used along with `source-map-support`, you can also get source maps.\n\n## Special Thanks\n\nThanks to [Colch](https://github.com/ColCh) for letting me take over development of a jest-webpack integration as the jest-webpack npm package.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmzgoddard%2Fjest-webpack","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmzgoddard%2Fjest-webpack","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmzgoddard%2Fjest-webpack/lists"}