{"id":28365303,"url":"https://github.com/toolbuilder/rollup-plugin-test-tools","last_synced_at":"2025-10-10T10:45:08.044Z","repository":{"id":57167202,"uuid":"388140671","full_name":"toolbuilder/rollup-plugin-test-tools","owner":"toolbuilder","description":"Supports pack file testing for dual modules using Rollup","archived":false,"fork":false,"pushed_at":"2023-08-12T17:55:01.000Z","size":193,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-08T23:25:23.610Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/toolbuilder.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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-07-21T14:19:09.000Z","updated_at":"2022-01-07T18:30:40.000Z","dependencies_parsed_at":"2022-08-30T15:21:58.534Z","dependency_job_id":null,"html_url":"https://github.com/toolbuilder/rollup-plugin-test-tools","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/toolbuilder/rollup-plugin-test-tools","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toolbuilder%2Frollup-plugin-test-tools","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toolbuilder%2Frollup-plugin-test-tools/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toolbuilder%2Frollup-plugin-test-tools/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toolbuilder%2Frollup-plugin-test-tools/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/toolbuilder","download_url":"https://codeload.github.com/toolbuilder/rollup-plugin-test-tools/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toolbuilder%2Frollup-plugin-test-tools/sbom","scorecard":{"id":894234,"data":{"date":"2025-08-11","repo":{"name":"github.com/toolbuilder/rollup-plugin-test-tools","commit":"7ba9c0c8f7388877f6106dd62a80b7a502de9581"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.1,"checks":[{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Code-Review","score":0,"reason":"Found 0/22 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":3,"reason":"7 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-968p-4wvh-cqc8","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv","Warn: Project is vulnerable to: GHSA-mwcw-c2x4-8c55","Warn: Project is vulnerable to: GHSA-gcx4-mw62-g8wm"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-24T13:03:52.959Z","repository_id":57167202,"created_at":"2025-08-24T13:03:52.960Z","updated_at":"2025-08-24T13:03:52.960Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279003546,"owners_count":26083595,"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-10-10T02:00:06.843Z","response_time":62,"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":[],"created_at":"2025-05-28T21:10:35.858Z","updated_at":"2025-10-10T10:45:08.031Z","avatar_url":"https://github.com/toolbuilder.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Rollup Plugin Test Tools\n\n[Rollup.js](https://www.rollupjs.org/) configurations to test your [pack file](https://docs.npmjs.com/cli/v6/commands/npm-pack) before publishing. It runs your unit tests against your packfile in an ES project, a CommonJS project, and in [Electron](https://www.electronjs.org/). This is primarily for [dual module](https://nodejs.org/api/packages.html#dual-commonjses-module-packages) packages.\n\nThere are also configurators that let you tweak the configurations a bit to meet your needs. If that's not good enough, this package re-exports a number of Rollup plugins for convenience.\n\nHere are the basic steps and some of the plugins used:\n\n* converts your units tests so that they use package instead of relative imports (e.g. `\"../src/index.js\"` to `\"your-package-name\"`)\n  * [rollup-plugin-multi-input](https://github.com/alfredosalzillo/rollup-plugin-multi-input)\n  * [rollup-plugin-relative-to-package](https://github.com/toolbuilder/rollup-plugin-relative-to-package)\n* builds ES, CommonJS, and browser (runs in Electron) test projects around those tests\n  * [rollup-plugin-create-test-package-json](https://github.com/toolbuilder/rollup-plugin-create-test-package-json)\n  * [rollup-plugin-create-pack-file](https://github.com/toolbuilder/rollup-plugin-create-pack-file)\n* and run the unit tests in the temporary test project\n  * [@toolbuilder/rollup-plugin-commands](https://github.com/toolbuilder/rollup-plugin-commands)\n\nThe configurations have these requirements:\n\n* Unit tests are written as ES modules.\n* Since your pack file is being tested, the unit tests must use only package imports that are accessible when using the package.\n\nThe default configurations also expect this:\n\n* Unit tests match this glob `test/**/*test.js`\n* Source code matches this glob `src/**/*.js`\n* Unit tests produce TAP output and are standalone - I use [zora](https://www.npmjs.com/package/zora) because it also runs in the browser.\n* The [pnpm](https://pnpm.io/) package manager is installed globally on your system for the temporary projects to use.\n* Rollup can produce a UMD file for your package, your tests, and all their dependencies.\n\n## Install\n\n```bash\nnpm install --save-dev @toolbuilder/rollup-plugin-test-tools\n```\n\n## Use\n\nJust create a a `rollup.config.js` [configuration file](https://www.rollupjs.org/guide/en/#configuration-files) like this:\n\n```javascript\n// Runs ES module test, CommonJS module test, then browser test in Electron\nexport { testConfigs as default } from '@toolbuilder/rollup-plugin-test-tools'\n```\n\nIf you just want to run your tests in [Node](https://nodejs.org/) only, then your `rollup.config.js` [configuration file](https://www.rollupjs.org/guide/en/#configuration-files) could look like this:\n\n```javascript\n// Runs ES module test and CommonJS module test\nexport { nodeConfigs as default } from '@toolbuilder/rollup-plugin-test-tools'\n```\n\nIf your tests are in the `testpack` directory instead of `tests`, then your `rollup.config.js` [configuration file](https://www.rollupjs.org/guide/en/#configuration-files) could look like this:\n\n```javascript\nimport { baseTestConfig } from '@toolbuilder/rollup-plugin-test-tools'\n\nconst options = { testSourceDir: 'testpack' }\n// Runs ES module test, CommonJS module test, then browser test in Electron\nexport default baseTestConfig(options)\n```\n\nIf you need to convert your pack file tests to ES modules first, you can insert your rollup plugin to do that.\n\n```javascript\nimport { baseTestConfig } from '@toolbuilder/rollup-plugin-test-tools'\n\nconst yourRollupConfiguration = { /* your configuration */ }\nconst options = { testSourceDir: 'testpack' }\n// This project always returns an Array of Rollup configurations,\n// so just use the spread operator to concatenate.\nexport default [yourRollupConfiguration, ...baseTestConfig(options)]\n\n```\n\n**NOTE** All configurations returned by this package are `Arrays` so that they can all be handled in a consistent manner. This is because some configurations require multiple configurations to perform the test.\n\n## API\n\nThis package exports quite a few functions and configurations.\n\n### Stock Rollup Configurations\n\nHere are the export statments for the stock configurations. The methods `baseBrowserTestConfig` and `basePackFileTestConfig` are documented in the next section.\n\n```javascript\n// NOTE: Rollup plugins cannot always be reused!!! So each configuration is created separately.\n\n// Test your pack file (after conversion to UMD) in Electron (e.g. browser environment)\nexport const browserTestConfig = baseBrowserTestConfig()\n// Test your pack file in an ES (i.e. { \"type\": \"module\" }) Node project\nexport const nodeEsTestConfig = basePackfileTestConfig()\n// Test your pack file in a CommonJS (i.e. { \"type\": \"commonjs\" }) Node project\nexport const nodeCommonJsTestConfig = basePackfileTestConfig({ format: 'cjs' })\n// ES and CommonJS tests combined\nexport const nodeConfigs = [...basePackfileTestConfig(), ...basePackfileTestConfig({ format: 'cjs' })]\n// ES, CommonJS, and Electron tests combined\nexport const baseTestConfig = (options = {}) =\u003e {\n  return [\n    ...basePackfileTestConfig({ format: 'cjs', ...options }),\n    ...basePackfileTestConfig(options),\n    ...baseBrowserTestConfig(options)\n  ]\n}\n```\n\nAs noted above, the browser test builds a UMD file from your pack file **and your unit tests**. Most likely you will need a custom configuration.\n\n### Configurators\n\nTwo configurable methods generate the tests.\n\n* `basePackfileTestConfig(options = {})` **{Object[]}** - this method generates a Rollup configuration to test your pack file in a Node project. The option parameters are described in the next section.\n* `baseBrowserTestConfig(options = {})` **{Object[]}** - this method generates a Rollup configuration to test your pack file in an Electron project. The option parameters are described in the next section.\n\n### Configurator Options\n\nThe test configurations in the [testpack](./testpack) directory of this project provide some examples.\n\nThese options tell the plugin where to find the test files and your source:\n\n* `testSourceDir` **{String}** - the directory where your pack file tests are. This is relative to your project structure. The default value is `test`.\n* `input` **{String[]}** - Array of globs that specify what tests to use for packfile testing. The input globs are passed to [rollup-plugin-multiinput](https://github.com/alfredosalzillo/rollup-plugin-multi-input), and are processed by [micromatch](https://github.com/micromatch/micromatch). The default value is ```[`${testSourceDir}/**/*test.js`]```.\n* `modulePaths` **{String}** - glob specify your source files. This is used to figure out  which test source imports to translate to package imports. The value is passed to [rollup-plugin-relative-to-package](https://github.com/toolbuilder/rollup-plugin-relative-to-package). By default the value is `src/**/*.js`.\n\nThese options tell the plugin where to put the temporary test project that tests your pack file.\n\n* `packageId` **{String}**  - to help trouble shooting, prepend this value to the default temporary directory used for testing so it is easier to find. Default value is 'package-test'.\n* `testPackageDir` **{String}** - specifies where the test project will be created. If this option is specified, the packageId option will be ignored. The default value is a unique directory in your OS temporary directory structure. The most recent testPackageDir will sort last.\n\nThese options tell the plugin how to configure the project that tests your pack file and run the tests:\n\n* `format` **{String}** - Passed to Rollup to specfiy whether tests will be generated as 'es' or 'cjs'. This is only used by `basePackfileTestConfig`.\n* `packCommand` **{String}** - Specify how to generate your pack file (e.g. 'npm pack' or 'pnpm pack'). The default value is `pnpm pack`.\n* `testPackageJson` **{Object|Promise}** - partial package.json to provide test scripts and dependencies to the test project. It is passed to [@toolbuilder/rollup-plugin-create-test-package-json](https://github.com/toolbuilder/rollup-plugin-create-test-package-json).\n* `checkSemverConflicts` **{boolean}** - check for semver conflicts between testPackageJson and your package.json. This value is passed to [@toolbuilder/rollup-plugin-create-test-package-json](https://github.com/toolbuilder/rollup-plugin-create-test-package-json). The default value in this package is `true`.\n* `installCommands` **{function[]}** - Array of function commands to install test project dependencies. The commands are passed to [@toolbuilder/rollup-plugin-commands](https://github.com/toolbuilder/rollup-plugin-commands) to run. The default value is ```[shellCommand(`pnpm -C ${testPackageDir} install`)]```. BTW, `shellCommand` is exported by this package, and is from ['@toolbuilder/rollup-plugin-commands'](https://github.com/toolbuilder/rollup-plugin-commands).\n* `testCommands` **{function[]}** - Array of commands to run test project tests. These are passed to the same plugin as the `installCommands`. The default value is ```[shellCommand(`pnpm -C ${testPackageDir} test`)]```. BTW, `shellCommand` is exported by this package, and is from ['@toolbuilder/rollup-plugin-commands'](https://github.com/toolbuilder/rollup-plugin-commands).\n\nThese options help tell the browser test how to build the UMD file that runs in Electron.\n\n* `external` **{String[]}** - Rollup external dependencies, passed directly to Rollup. This option is only used by `baseBrowserTestConfig`.\n* `globals` - **{Object}** - Rollup global names, passed directly to Rollup. This option is only used by `baseBrowserTestConfig`.\n\n### TempPath\n\n* `tempPath(prefix = 'package-test')` **{String}** - This function creates a unique temporary path name in your OS's temporary directory, but does not create the directory itself. The name includes a timestamp so the most recent one sorts last. The parameter `prefix` is prependended to the temporary name.\n\n### Exported Dependencies\n\nSome of this package's dependencies are exported for convenience. Links to documentation for these packages are provided above.\n\n```javascript\n// These are the export statements\nexport { default as alias } from '@rollup/plugin-alias'\nexport { default as multiEntry } from '@rollup/plugin-multi-entry'\nexport { default as resolve } from '@rollup/plugin-node-resolve'\nexport { default as runCommands, shellCommand } from '@toolbuilder/rollup-plugin-commands'\nexport { default as createPackFile } from '@toolbuilder/rollup-plugin-create-pack-file'\nexport { default as createTestPackageJson } from 'rollup-plugin-create-test-package-json'\nexport { default as multiInput } from 'rollup-plugin-multi-input'\nexport { default as relativeToPackage } from 'rollup-plugin-relative-to-package'\n```\n\n## Stability\n\nThis package will have a looser interpretation of [semver](https://semver.org/) numbering. For example adding [@rollup/plugin-commonjs](https://github.com/rollup/plugins/tree/master/packages/commonjs) to the browser configuration does not affect my projects, but it might affect yours. So what I might think it is a small point change, might be a breaking change for you.\n\n## Contributing\n\nI hope you find this project useful enough to contribute. Please create an issue or a pull request.\n\n* I use [pnpm](https://pnpm.js.org/) instead of npm.\n* Package verification requires [pnpm](https://pnpm.io/) to be installed globally.\n  * `npm install -g pnpm`\n  * `pnpm install`\n  * `pnpm run check:packfile` to test against Node ES and CommonJS projects, as well as Electron.\n  * `pnpm run check` to validate the package is ready for commit\n\n## Issues\n\nThis project uses Github issues.\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftoolbuilder%2Frollup-plugin-test-tools","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftoolbuilder%2Frollup-plugin-test-tools","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftoolbuilder%2Frollup-plugin-test-tools/lists"}