{"id":19677720,"url":"https://github.com/3rd-eden/setup-env","last_synced_at":"2025-08-20T01:05:20.095Z","repository":{"id":32863841,"uuid":"144642781","full_name":"3rd-Eden/setup-env","owner":"3rd-Eden","description":"Automated, feature detected, environment setup for your test suite","archived":false,"fork":false,"pushed_at":"2023-07-14T12:09:50.000Z","size":78,"stargazers_count":3,"open_issues_count":1,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-09T15:52:31.730Z","etag":null,"topics":["babel","environment","enzyme","jsdom","react","setup","test","testing"],"latest_commit_sha":null,"homepage":null,"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/3rd-Eden.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"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-08-13T23:07:04.000Z","updated_at":"2023-01-26T15:22:03.000Z","dependencies_parsed_at":"2024-06-19T00:15:46.158Z","dependency_job_id":"57f45340-b96c-4a99-b39c-1b9378357f32","html_url":"https://github.com/3rd-Eden/setup-env","commit_stats":{"total_commits":19,"total_committers":5,"mean_commits":3.8,"dds":"0.21052631578947367","last_synced_commit":"ae084c630796f9b0227e733d14eacabc539ea65c"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/3rd-Eden/setup-env","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/3rd-Eden%2Fsetup-env","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/3rd-Eden%2Fsetup-env/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/3rd-Eden%2Fsetup-env/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/3rd-Eden%2Fsetup-env/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/3rd-Eden","download_url":"https://codeload.github.com/3rd-Eden/setup-env/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/3rd-Eden%2Fsetup-env/sbom","scorecard":{"id":3736,"data":{"date":"2025-08-11","repo":{"name":"github.com/3rd-Eden/setup-env","commit":"1aecaf0b66ebbf6af255c49c81ce3c1046b47890"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.7,"checks":[{"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":"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":"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":"Code-Review","score":1,"reason":"Found 2/20 approved changesets -- score normalized to 1","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":"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":"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":"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":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"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":0,"reason":"license file not detected","details":["Warn: project does not have a license file"],"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":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 4 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-14T13:06:51.026Z","repository_id":32863841,"created_at":"2025-08-14T13:06:51.026Z","updated_at":"2025-08-14T13:06:51.026Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271247542,"owners_count":24725924,"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-08-19T02:00:09.176Z","response_time":63,"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":["babel","environment","enzyme","jsdom","react","setup","test","testing"],"created_at":"2024-11-11T17:35:10.434Z","updated_at":"2025-08-20T01:05:20.065Z","avatar_url":"https://github.com/3rd-Eden.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# setup-env\n\nWe've reached peak programming. Complex toolchains making our development lives\neasier. So why not apply this to testing. But instead of complex, we just\nrun a couple of scripts, instead of massive configuration files, just nothing\nand instead of you writing code, a module that does it for you. Sounds to good\nto be true? It probably is, sorry.\n\nYou might wonder how this project will actually help you out, it automates the\nfollowing setup process's for your tests:\n\n- Babel integration, ensures your tests are compiled with the same babel presets\n  as the rest of your code.\n- Set the correct env, something that is easily forgotten, `NODE_ENV=test`, but\n  we gotchu fam.\n- Support for loading static files using `require`. Not as fancy as WebPack, at\n  least it will make your code run instead of throw.\n- Shallow rendering, correctly setup and pre-configured with JSDOM, as it should.\n\nStill not convinced? Here's some _expert_ reviews:\n\n```\nThis shizz is lit fam       require, done, izipizi    Best module ever installed\n          - Ya homies            - Your co-workers              - Everybody else\n```\n\n/s\n\n## Installation\n\nThe package is released in the public npm registry under the `setup-env` name\nand should be installed as `devDependency` in your project:\n\n```\nnpm install --save-dev setup-env\n```\n\nThen require the file before your tests are imported, for example with `mocha`\nyou can use the `--require` file to achieve this:\n\n```\nmocha --require setup-env ./test/*.test.js\n```\n\nAnd for `jest` you can leverage the `setupFiles` array in your `jest.config.js`:\n\n```js\n{\n  setupFiles: ['setup-env']\n}\n```\n\nAnd that's it, your project is configured.\n\n## Configuration\n\nFirst of all, **configuration is optional**, this library works out of the box\nfor the dependencies you have installed in your project. Customizing how we\nsetup the environment is done using a special `setup` key in your `package.json`:\n\n```js\n{\n  \"name\": \"example-package\",\n  \"description\": \"ignore this, this is content filler\",\n  ...\n\n  \"setup\": {\n    \"userAgent\": \"Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.9)\"\n  },\n\n  ...\n  \"devDependencies\": {\n    \"@babel/register\": \"latest\",\n    \"enzyme-adapter-react-17\": \"latest\",\n    ...\n  }\n}\n```\n\nThe following keys inside the `setup` object can be configured:\n\n- [steps](#steps)\n- [babel](#babel)\n- [jsdom](#jsdom)\n- [enzyme](#enzyme)\n- [loaders](#loaders)\n- [extensions](#extensions)\n\n### steps\n\nThese are the steps that we execute (in order) to prepare the environment for\ntesting. The following steps are executed:\n\n- `env` Ensure that a proper `NODE_ENV` is set before testing.\n- `register` Enable `@babel/register` or the ancient `babel-register`.\n- `enzyme` Automatically configure the Enzyme adapter.\n- `jsdom` Prepare the environment with JSDOM.\n- `static` Allows requiring of static files such as `.css` and `.jpg` files.\n\n```js\n{\n  \"setup\": {\n    \"steps\": ['static']\n  }\n}\n```\n\nThe code above will prevent every step to run, except our `static` integration.\nPlease note, that you don't need to explicitly turn off the `enzyme` or\n`register` steps if you don't use `@babel/register` or `enzyme` in your project.\nThis project is smart enough to ignore them if they are not installed.\n\n### babel\n\nProvide custom options to the `@babel/register` loader. This gives you full\ncontrol on how babel processes the files that you require in your test suite.\n\n```js\n{\n  \"setup\": {\n    \"babel\": {\n      \"cache\": false\n    }\n  }\n}\n```\n\nIt also support the ancient `babel-register` package, if you are building a\nnew project we encourage you to use the latest and greatest.\n\n### jsdom\n\nIntroduces JSDOM based globals in the environment so you can use `window`,\n`document` and other DOM based globals in your test suite without issues.\nAdditionally this will ensure that the `{ mount }` functionality of `enzyme`\nworks.\n\n```js\n{\n  \"setup\": {\n    \"jsdom\": {\n      \"storageQuota\": 10000000,\n      \"referrer\": \"https://example.com/\"\n    }\n  }\n}\n```\n\nAdditional, the `userAgent` can be configured using the `userAgent` key in\n`setup`.\n\n### enzyme\n\nWe currently do a best effort in finding the correct Enzyme adapter. We'll\nsearch your dependencies for package names that match the\n`enzyme-adapter-react-(version number)` string and use those as adapters. When\nwe're unable to find these adapters we'll start guessing which adapter to use\nbased on the `react` version you have installed as dependency.\n\nIf everything fails, or you have to resolve to using a custom adapter you can\nforce the resolving of the adapter through our configuration.\n\n```js\n{\n  \"setup\": {\n    \"enzyme\": {\n      \"adapter\": \"@wojtekmaj/enzyme-adapter-react-17\"\n    }\n  }\n}\n```\n\n### extensions\n\nIt's not uncommon that you compile your code with WebPack and that you import\nasserts inside your code such as css files or static images. These are not\nsupported by Node as it only understands JavaScript. We will automatically\npatch the environment to ensure that these dependencies can be loaded inside\nNode.js. The `extensions` option allows you to configure which extensions need\nto be patched. We have a list with common media types for css, fonts, images\nand video/audio files. But you can create your own list using this option.\n\n```js\n{\n  \"setup\": {\n    \"extensions\": [\n      \".css\",\n      \".sass\",\n      \".example\"\n    ]\n  }\n}\n```\n\n### loaders\n\nThis option is used in pair with the `extensions` configuration. By default we\nwill have the custom extension support return the path of the file that is\nloaded so you can easily assert that the correct files are loaded. However it's\npossible that you want to have a custom loader, so you can return something\nelse. The loaders object allows you to provide a mapping between extensions\nand custom loader files that can be required.\n\n```js\n{\n  \"setup\": {\n    \"loaders\": {\n      \".css\": \"css-loader-module-name\"\n    }\n  }\n}\n```\n\nAnd the `css-loader-module-name` module would export a function that receives\na `Module` instance that it can update with what ever it wants to process.\n\n```js\nmodule.exports = function customloader(Module) {\n  Module.exports = require('fs').readFileSync(Module.filename);\n}\n```\n\n## Debugging\n\nThis library makes use of `diagnostics` to provide debug information incase\nof unexpected failure when preparing the environment. In order to see these\nlogs you need to start the tests with `DEBUG=setup-env*`:\n\n```\nDEBUG=setup-env* npm test\n```\n\n## License\n\n[MIT](/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F3rd-eden%2Fsetup-env","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F3rd-eden%2Fsetup-env","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F3rd-eden%2Fsetup-env/lists"}