This repository has been archived by the owner on Jan 26, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ava-env): Implement test specific environment variables
- Loading branch information
Matt Searle
committed
May 3, 2019
1 parent
c6edefa
commit d5c635f
Showing
5 changed files
with
41 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,14 @@ | ||
const test = require('ava'); | ||
const env = require('../env'); | ||
|
||
test('Init test file', t => t.pass()); | ||
test('Ava-env - Should add variables to process.env', t => { | ||
|
||
}); | ||
|
||
test('Ava-env - Should overwrite process.env variables', t => { | ||
|
||
}); | ||
|
||
test('Ava-env - Should clean up process.env after the unit tests', t => { | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,23 @@ | ||
module.exports = require('ava'); | ||
const test = require('ava'); | ||
const deepClone = require('lodash.clonedeep'); | ||
|
||
const env = test => { | ||
const envCache = Symbol('envCache'); | ||
|
||
test.beforeEach(t => { | ||
t.context[envCache] = deepClone(process.env); | ||
|
||
t.context.env = envVar => { | ||
process.env = { | ||
...process.env, | ||
...envVar | ||
}; | ||
}; | ||
}); | ||
|
||
test.afterEach(t => { | ||
process.env = t.context[envCache]; | ||
}); | ||
}; | ||
|
||
module.exports = env; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters