{"id":16347634,"url":"https://github.com/privatenumber/webpack-test-utils","last_synced_at":"2025-06-20T12:05:34.451Z","repository":{"id":46091162,"uuid":"422971279","full_name":"privatenumber/webpack-test-utils","owner":"privatenumber","description":"Utility functions to test Webpack loaders/plugins","archived":false,"fork":false,"pushed_at":"2022-12-15T07:58:06.000Z","size":569,"stargazers_count":9,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"develop","last_synced_at":"2025-03-18T16:04:15.085Z","etag":null,"topics":["loader","plugin","test","util","utils","webpack"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/privatenumber.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-10-30T19:20:58.000Z","updated_at":"2025-02-03T03:00:38.000Z","dependencies_parsed_at":"2023-01-29T02:30:53.743Z","dependency_job_id":null,"html_url":"https://github.com/privatenumber/webpack-test-utils","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/privatenumber%2Fwebpack-test-utils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/privatenumber%2Fwebpack-test-utils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/privatenumber%2Fwebpack-test-utils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/privatenumber%2Fwebpack-test-utils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/privatenumber","download_url":"https://codeload.github.com/privatenumber/webpack-test-utils/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245040235,"owners_count":20551297,"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":["loader","plugin","test","util","utils","webpack"],"created_at":"2024-10-11T00:44:21.492Z","updated_at":"2025-03-23T00:32:56.322Z","avatar_url":"https://github.com/privatenumber.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# webpack-test-utils \u003ca href=\"https://npm.im/webpack-test-utils\"\u003e\u003cimg src=\"https://badgen.net/npm/v/webpack-test-utils\"\u003e\u003c/a\u003e \u003c!-- \u003ca href=\"https://npm.im/webpack-test-utils\"\u003e\u003cimg src=\"https://badgen.net/npm/dm/webpack-test-utils\"\u003e\u003c/a\u003e --\u003e\u003ca href=\"https://packagephobia.now.sh/result?p=webpack-test-utils\"\u003e\u003cimg src=\"https://packagephobia.now.sh/badge?p=webpack-test-utils\"\u003e\u003c/a\u003e\n\nUtility functions to test Webpack loaders/plugins\n\n### Features\n- **In-memory builds** Uses an in-memory file-system for faster builds that don't pollute your disk\n- **TypeScript support** Get type hints and develop with confidence\n- **Sensible defaults** Builds in production-mode by default with minification disabled\n- **Webpack 4 \u0026 5 support** Both versions are supported\n\n## 🚀 Install\n```bash\nnpm i -D webpack-test-utils\n```\n\n## 👨‍🏫 Usage\n\n### Build\n```js\nimport { build } from 'webpack-test-utils'\n\ntest('build', async () =\u003e {\n    // Create in-memory file-system\n    const volume = {\n        '/src/index.js': 'export default \"12345\"'\n    }\n\n    // Run Webpack build\n    const built = await build(volume)\n\n    // Verify successful build\n    expect(built.stats.hasErrors()).toBe(false)\n    expect(built.stats.hasWarnings()).toBe(false)\n\n    // Run the code to verify result\n    expect(built.require('/dist/index.js')).toBe('12345')\n})\n```\n\n### Watch\n```js\nimport { watch } from 'webpack-test-utils'\n\ntest('watch', async () =\u003e {\n    // Create in-memory file-system\n    const volume = {\n        '/src/index.js': 'export default \"12345\"'\n    }\n\n    // Create Webpack watcher\n    const watching = watch(volume)\n\n    // Create build\n    let stats = await watching.build()\n\n    // Verify result\n    expect(stats.hasWarnings()).toBe(false)\n    expect(watching.require('/dist')).toBe('12345')\n\n    // Update source code\n    watching.fs.writeFileSync('/src/index.js', 'export default \"54321\"')\n\n    // Rebuild\n    stats = await watching.build()\n\n    expect(stats.hasWarnings()).toBe(false)\n\n    // Delete cache and re-require to validate changed result\n    delete watching.require.cache[watching.require.resolve('/dist')]\n    expect(watching.require('/dist')).toBe('54321')\n\n    // Close watcher\n    await watching.close()\n})\n```\n\n\n## ⚙️ API\n\n### build(volume, configHook)\n\nReturns: `Promise\u003cWebpackStats\u003e`\n\nRun a single Webpack build.\n#### volume\n\nType: `{ [filePath: string]: string }`\n\nRequired\n\nAn object where the key is the absolute path, and the value is the content of the path.\n\n#### configurationHook\n\nType: `(config: WebpackConfiguration) =\u003e void`\n\nA function that receives the Webpack configuration object for configuration before running the build.\n\n\n### watch(volume, configHook)\n\nReturns: `Promise\u003cWebpackStats\u003e`\n\nRun a single Webpack build.\n#### volume\n\nType: `{ [filePath: string]: string }`\n\nRequired\n\nAn object where the key is the absolute path, and the value is the content of the path.\n\n#### configurationHook\n\nType: `(config: WebpackConfiguration) =\u003e void`\n\nA function that receives the Webpack configuration object for configuration before running the build.\n\n\n### Default Webpack configuration\n\nSee [`src/utils/get-default-webpack-config.ts`](/src/utils/get-default-webpack-config.ts).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprivatenumber%2Fwebpack-test-utils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprivatenumber%2Fwebpack-test-utils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprivatenumber%2Fwebpack-test-utils/lists"}