{"id":21659196,"url":"https://github.com/codymikol/karma-webpack","last_synced_at":"2025-12-16T23:49:05.904Z","repository":{"id":12963782,"uuid":"15642187","full_name":"codymikol/karma-webpack","owner":"codymikol","description":"Karma webpack Middleware","archived":false,"fork":false,"pushed_at":"2024-08-31T01:47:24.000Z","size":2628,"stargazers_count":828,"open_issues_count":9,"forks_count":214,"subscribers_count":21,"default_branch":"master","last_synced_at":"2025-11-30T22:55:10.158Z","etag":null,"topics":["karma","webpack-plugin"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/codymikol.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-01-05T00:10:21.000Z","updated_at":"2025-09-12T03:00:11.000Z","dependencies_parsed_at":"2023-02-14T12:17:18.624Z","dependency_job_id":"7589deef-f7dd-4951-9bc1-5364e06c3681","html_url":"https://github.com/codymikol/karma-webpack","commit_stats":null,"previous_names":["webpack-contrib/karma-webpack","webpack/karma-webpack","ryanclark/karma-webpack"],"tags_count":44,"template":false,"template_full_name":null,"purl":"pkg:github/codymikol/karma-webpack","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codymikol%2Fkarma-webpack","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codymikol%2Fkarma-webpack/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codymikol%2Fkarma-webpack/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codymikol%2Fkarma-webpack/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codymikol","download_url":"https://codeload.github.com/codymikol/karma-webpack/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codymikol%2Fkarma-webpack/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":27537930,"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","status":"online","status_checked_at":"2025-12-06T02:00:06.463Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["karma","webpack-plugin"],"created_at":"2024-11-25T09:30:39.199Z","updated_at":"2025-12-16T23:49:05.888Z","avatar_url":"https://github.com/codymikol.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"[![npm][npm]][npm-url]\n[![node][node]][node-url]\n[![coverage][cover]][cover-url]\n\n\u003cdiv align=\"center\"\u003e\n  \u003ca href='https://github.com/karma-runner/karma'\u003e\n    \u003cimg width=\"180\" height=\"180\"\n      src=\"https://worldvectorlogo.com/logos/karma.svg\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/webpack/webpack\"\u003e\n    \u003cimg width=\"200\" height=\"200\"\n      src=\"https://cdn.rawgit.com/webpack/media/e7485eb2/logo/icon.svg\"\u003e\n  \u003c/a\u003e\n  \u003ch1\u003eKarma Webpack\u003c/h1\u003e\n  \u003cp\u003eUse webpack to preprocess files in karma\u003cp\u003e\n\u003c/div\u003e\n\n\u003ch2 align=\"center\"\u003eInstall\u003c/h2\u003e\n\nnpm `npm i -D karma-webpack`\n\nyarn `yarn add -D karma-webpack`\n\n\u003ch2 align=\"center\"\u003eUsage\u003c/h2\u003e\n\n**karma.conf.js**\n```js\nmodule.exports = (config) =\u003e {\n  config.set({\n    // ... normal karma configuration\n\n    // make sure to include webpack as a framework\n    frameworks: ['mocha', 'webpack'],\n    \n    plugins: [\n      'karma-webpack',\n      'karma-mocha',\n    ],\n\n    files: [\n      // all files ending in \".test.js\"\n      // !!! use watched: false as we use webpacks watch\n      { pattern: 'test/**/*.test.js', watched: false }\n    ],\n\n    preprocessors: {\n      // add webpack as preprocessor\n      'test/**/*.test.js': [ 'webpack' ]\n    },\n\n    webpack: {\n      // karma watches the test entry points\n      // Do NOT specify the entry option\n      // webpack watches dependencies\n\n      // webpack configuration\n    },\n  });\n}\n```\n\n### Default webpack configuration\n\nThis configuration will be merged with what gets provided via karma's config.webpack.\n\n```js\nconst defaultWebpackOptions = {\n  mode: 'development',\n  output: {\n    filename: '[name].js',\n    path: path.join(os.tmpdir(), '_karma_webpack_') + Math.floor(Math.random() * 1000000),\n  },\n  stats: {\n    modules: false,\n    colors: true,\n  },\n  watch: false,\n  optimization: {\n    runtimeChunk: 'single',\n    splitChunks: {\n      chunks: 'all',\n      minSize: 0,\n      cacheGroups: {\n        commons: {\n          name: 'commons',\n          chunks: 'initial',\n          minChunks: 1,\n        },\n      },\n    },\n  },\n  plugins: [],\n};\n```\n\n### How it works\n\nThis project is a framework and preprocessor for Karma that combines test files and dependencies into 2 shared bundles and 1 chunk per test file. It relies on webpack to generate the bundles/chunks and to keep it updated during `autoWatch=true`.\n\nThe first preproccessor triggers the build of all the bundles/chunks and all following files just return the output of this one build process.\n\n### Webpack typescript support\n\nBy default karma-webpack forces *.js files so if you test *.ts files and use webpack to build typescript to javascript it works out of the box.\n\nIf you have a different need you can override by setting `webpack.transformPath`\n\n```js\n// this is the by default applied transformPath\nwebpack: {\n  transformPath: (filepath) =\u003e {\n      // force *.js files by default\n      const info = path.parse(filepath);\n      return `${path.join(info.dir, info.name)}.js`;\n    },\n},\n```\n\n### `Source Maps`\n\nYou can use the `karma-sourcemap-loader` to get the source maps generated for your test bundle.\n\n```bash\nnpm i -D karma-sourcemap-loader\n```\n\nAnd then add it to your preprocessors.\n\n**karma.conf.js**\n```js\npreprocessors: {\n  'test/test_index.js': [ 'webpack', 'sourcemap' ]\n}\n```\n\nAnd tell `webpack` to generate sourcemaps.\n\n**webpack.config.js**\n```js\nwebpack: {\n  // ...\n  devtool: 'inline-source-map'\n}\n```\n\n\u003ch2 align=\"center\"\u003eCurrent Maintainers\u003c/h2\u003e\n\n\u003ctable\u003e\n  \u003ctbody\u003e\n    \u003ctr\u003e\n      \u003ctd\u003e\n        \u003cimg width=\"150\" height=\"150\"\n             src=\"https://avatars.githubusercontent.com/u/13606342?s=460\u0026u=467cf9a106d2bb474cf627ffd4e0eac80d0b4705\u0026v=4\"\u003e\n        \u003cbr\u003e\n        \u003ca href=\"http://codymikol.com\"\u003eCody Mikol\u003c/a\u003e\n      \u003c/td\u003e\n    \u003c/tr\u003e\n  \u003ctbody\u003e\n\u003c/table\u003e\n\n\u003ch2 align=\"center\"\u003ePrevious Maintainers\u003c/h2\u003e\n\nPrevious maintainers of the `karma-webpack` plugin that have done such amazing work to get it to where it is today.\n\n\u003ctable class=\"maintainers\"\u003e\n  \u003ctbody\u003e\n    \u003ctr\u003e\n      \u003ctd align=\"center\"\u003e\n        \u003cimg width=\"150\" height=\"150\"\n        src=\"https://avatars0.githubusercontent.com/u/7922109?v=4\u0026s=150\"\u003e\n        \u003cbr\u003e\n        \u003ca href=\"https://github.com/ryanclark\"\u003eRyan Clark\u003c/a\u003e\n      \u003c/td\u003e\n      \u003ctd align=\"center\"\u003e\n        \u003cimg width=\"150\" height=\"150\"\n        src=\"https://avatars3.githubusercontent.com/u/2045543?v=4\u0026s=150\"\u003e\n        \u003cbr\u003e\n        \u003ca href=\"https://github.com/AprilArcus\"\u003eApril Arcus\u003c/a\u003e\n      \u003c/td\u003e\n      \u003ctd align=\"center\"\u003e\n        \u003cimg width=\"150\" height=\"150\"\n        src=\"https://avatars.githubusercontent.com/u/4650931?v=3\u0026s=150\"\u003e\n        \u003c/br\u003e\n        \u003ca href=\"https://github.com/MikaAK\"\u003eMika Kalathil\u003c/a\u003e\n      \u003c/td\u003e\n      \u003ctd align=\"center\"\u003e\n        \u003cimg width=\"150\" height=\"150\"\n        src=\"https://avatars.githubusercontent.com/u/8420490?v=3\u0026s=150\"\u003e\n        \u003ca href=\"https://github.com/d3viant0ne\"\u003eJoshua Wiens\u003c/a\u003e\n      \u003c/td\u003e\n      \u003ctd align=\"center\"\u003e\n        \u003cimg width=\"150\" height=\"150\" src=\"https://avatars.githubusercontent.com/u/1919664?v=3\u0026s=150\"\u003e\n        \u003ca href=\"https://github.com/goldhand\"\u003eWill Farley\u003c/a\u003e\n      \u003c/td\u003e\n      \u003ctd align=\"center\"\u003e\n        \u003cimg width=\"150\" height=\"150\"\n        src=\"https://avatars.githubusercontent.com/u/1307954?v=3\u0026s=150\"\u003e\n        \u003ca href=\"https://github.com/DanielaValero\"\u003eDaniela Valero\u003c/a\u003e\n      \u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003ctd align=\"center\"\u003e\n        \u003cimg width=\"150\" height=\"150\"\n        src=\"https://avatars.githubusercontent.com/u/122108?v=3\u0026s=150\"\u003e\n        \u003ca href=\"https://github.com/jon301\"\u003eJonathan Trang\u003c/a\u003e\n      \u003c/td\u003e\n      \u003ctd align=\"center\"\u003e\n        \u003cimg width=\"150\" height=\"150\"\n        src=\"https://avatars.githubusercontent.com/u/3285723?v=3\u0026s=150\"\u003e\n        \u003ca href=\"https://github.com/carlos-\"\u003eCarlos Morales\u003c/a\u003e\n      \u003c/td\u003e\n    \u003c/tr\u003e\n  \u003ctbody\u003e\n\u003c/table\u003e\n\n\n[npm]: https://img.shields.io/npm/v/karma-webpack.svg\n[npm-url]: https://npmjs.com/package/karma-webpack\n\n[node]: https://img.shields.io/node/v/karma-webpack.svg\n[node-url]: https://nodejs.org\n\n[cover]: https://codecov.io/gh/webpack-contrib/karma-webpack/branch/master/graph/badge.svg\n[cover-url]: https://codecov.io/gh/webpack-contrib/karma-webpack\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodymikol%2Fkarma-webpack","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodymikol%2Fkarma-webpack","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodymikol%2Fkarma-webpack/lists"}