{"id":17180767,"url":"https://github.com/jsok/karma-env-preprocessor","last_synced_at":"2025-04-13T17:13:44.456Z","repository":{"id":20532899,"uuid":"23812148","full_name":"jsok/karma-env-preprocessor","owner":"jsok","description":"A Karma plugin to read environment variables and make them available inside your tests.","archived":false,"fork":false,"pushed_at":"2016-06-13T22:03:42.000Z","size":5,"stargazers_count":6,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-27T08:05:08.600Z","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/jsok.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":"2014-09-08T23:21:27.000Z","updated_at":"2020-08-19T06:21:45.000Z","dependencies_parsed_at":"2022-07-23T05:48:39.640Z","dependency_job_id":null,"html_url":"https://github.com/jsok/karma-env-preprocessor","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsok%2Fkarma-env-preprocessor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsok%2Fkarma-env-preprocessor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsok%2Fkarma-env-preprocessor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsok%2Fkarma-env-preprocessor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jsok","download_url":"https://codeload.github.com/jsok/karma-env-preprocessor/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248447956,"owners_count":21105207,"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":[],"created_at":"2024-10-15T00:31:33.661Z","updated_at":"2025-04-13T17:13:44.435Z","avatar_url":"https://github.com/jsok.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# karma-env-preprocessor\n\n[![npm version](https://badge.fury.io/js/karma-env-preprocessor.svg)](http://badge.fury.io/js/karma-env-preprocessor)\n\n\u003e Preprocessor which makes environment variables available to your tests.\n\n## Installation\n\nThe easiest way is to keep `karma-env-preprocessor` as a devDependency in your `package.json`.\n```json\n{\n  \"devDependencies\": {\n    \"karma\": \"~0.10\",\n    \"karma-env-preprocessor\": \"~0.1\"\n  }\n}\n```\n\nYou can simple do it by:\n```bash\nnpm install karma-env-preprocessor --save-dev\n```\n\nTo load `karma-env-preprocessor` into Karma you should add it to the plugins array in the Karma configuration file.\nFor more information see [the Plugins section](http://karma-runner.github.io/0.13/config/plugins.html) of the Karma documentation.\n\n## Configuration\nAny files you preprocess using this plugin will be affected, e.g for all JavaScript files:\n```js\n// karma.conf.js\nmodule.exports = function(config) {\n  config.set({\n    preprocessors: {\n      '**/*.js': ['env']\n    },\n\n    envPreprocessor: [\n      'PATH',\n      'HOME'\n    ],\n\n    plugins: [\n      'karma-env-preprocessor'\n    ],\n  });\n};\n```\n\n## How does it work ?\n\nThis preprocessor uses `process.env` to read the value of each environment variable specified in `envPreprocessor` and publishes them in the global `window.__env__`, so you can read these values in your tests.\n\nFor example, the above configuration will be served as:\n```js\nwindow.__env__ = window.__env__ || []\nwindow.__env__['PATH'] = '/usr/sbin:/usr/bin:/sbin:/bin';\nwindow.__env__['HOME'] = '/home/jsok';\n```\n\n----\n\nFor more information on Karma see the [homepage].\n\n\n[homepage]: http://karma-runner.github.com\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjsok%2Fkarma-env-preprocessor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjsok%2Fkarma-env-preprocessor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjsok%2Fkarma-env-preprocessor/lists"}