{"id":25170206,"url":"https://github.com/chocpanda/ava-env","last_synced_at":"2025-10-24T07:30:22.233Z","repository":{"id":56241748,"uuid":"184784180","full_name":"ChocPanda/ava-env","owner":"ChocPanda","description":"Test specific environment variables for ava","archived":false,"fork":false,"pushed_at":"2020-11-18T22:01:57.000Z","size":404,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-01-29T07:34:22.747Z","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/ChocPanda.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-05-03T16:03:56.000Z","updated_at":"2019-11-08T20:02:40.000Z","dependencies_parsed_at":"2022-08-15T15:20:21.875Z","dependency_job_id":null,"html_url":"https://github.com/ChocPanda/ava-env","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/ChocPanda%2Fava-env","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChocPanda%2Fava-env/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChocPanda%2Fava-env/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChocPanda%2Fava-env/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ChocPanda","download_url":"https://codeload.github.com/ChocPanda/ava-env/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237926579,"owners_count":19388577,"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":"2025-02-09T08:39:59.554Z","updated_at":"2025-10-24T07:30:21.876Z","avatar_url":"https://github.com/ChocPanda.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AVA-ENV\n\n\u003cp align=\"center\"\u003e\n\t\u003ca href=\"https://circleci.com/gh/ChocPanda/ava-env\" alt=\"CircleCI\"\u003e\n\t\t\u003cimg src=\"https://img.shields.io/circleci/project/github/ChocPanda/ava-env/master.svg?style=popout\" /\u003e\n\t\u003c/a\u003e\n\t\u003ca href=\"https://codecov.io/gh/ChocPanda/ava-env\" alt=\"codecov\"\u003e\n\t\t\u003cimg src=\"https://codecov.io/gh/ChocPanda/ava-env/branch/master/graph/badge.svg\" /\u003e\n\t\u003c/a\u003e\n\t\u003ca href=\"https://www.npmjs.com/package/ava-env\" alt=\"npm version\"\u003e\n\t\t\u003cimg src=\"https://img.shields.io/npm/v/ava-env.svg?style=popout\" /\u003e\n\t\u003c/a\u003e\n\t\u003ca href=\"https://david-dm.org/ChocPanda/ava-env\" alt=\"dependencies\"\u003e\n\t\t\u003cimg src=\"https://david-dm.org/ChocPanda/ava-env.svg\" /\u003e\n\t\u003c/a\u003e\n\t\u003ca href=\"https://github.com/ChocPanda/ava-env/blob/master/LICENSE\" alt=\"license\"\u003e\n\t\t\u003cimg src=\"https://img.shields.io/github/license/ChocPanda/ava-env.svg?style=popout\" /\u003e\n\t\u003c/a\u003e\n\t\u003ca href=\"https://github.com/xojs/xo\" alt=\"XO code style\"\u003e\n\t\t\u003cimg src=\"https://img.shields.io/badge/code_style-XO-5ed9c7.svg\" /\u003e\n\t\u003c/a\u003e\n\t\u003ca href=\"http://commitizen.github.io/cz-cli/\" alt=\"Commitizen friendly\"\u003e\n\t\t\u003cimg src=\"https://img.shields.io/badge/commitizen-friendly-brightgreen.svg\" /\u003e\n\t\u003c/a\u003e\n\t\u003ca href=\"https://github.com/semantic-release/semantic-release\" alt=\"semantic-release\"\u003e\n\t\t\u003cimg src=\"https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg\" /\u003e\n\t\u003c/a\u003e\n\t\u003ca href=\"https://greenkeeper.io/\" alt=\"Greenkeeper badge\"\u003e\n\t\t\u003cimg src=\"https://badges.greenkeeper.io/ChocPanda/ava-env.svg\" /\u003e\n\t\u003c/a\u003e\n\u003c/p\u003e\n\nQuick and dirty boilerplate to set and reset process.env variables when running tests in [ava](https://github.com/avajs/ava/)\n\n## Contents\n\n\u003c!-- toc --\u003e\n\n- [Usage](#usage)\n\n\u003c!-- tocstop --\u003e\n\n## Installation\n\n- Install using yarn:\n```yarn add ava ava-env -D```\n- Install using npm:\n```npm install ava ava-env --dev```\n\n## Usage\n\nThe tests should be run serially to ensure they aren't run on parallel processes or concurrently (as may be the case asynchronous tests) which could cause them to share a process.env.\n\nUsing `ava-env` means the process.env will be cleaned up after each test and returned to the state before the test started, meaning the process can be recycled for the next test without carrying over any global state/shared environment variables\n\n```javascript\nconst test = require('ava-env')(require('ava'));\n\ntest.serial('My test', t =\u003e {\n\tt.is(process.env.testEnvVar, undefined) // Not required...\n\tt.context.env({ testEnvVar: 'testValue' });\n\n\t// ... test code that requires environment variable to be set\n\n\tt.is(process.env.testEnvVar, 'testValue');\n});\n\ntest.serial('My other test', t =\u003e {\n\tt.is(process.env.testEnvVar, undefined) // Not required...\n\tt.context.env({ testEnvVar: 'different test value' });\n\n\t// ... test code that requires environment variable to be set\n\n\tt.is(process.env.testEnvVar, 'different test value');\n})\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchocpanda%2Fava-env","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchocpanda%2Fava-env","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchocpanda%2Fava-env/lists"}