mirror of
https://github.com/github/codeql-action
synced 2026-12-04 13:59:31 +08:00
reset environment variables between tests
This commit is contained in:
1 parent
ee63f4ee4b
commit
29cf06569d
6 files changed
+28
-3
No files matched your search
Generated
+7
@@ -51,6 +51,11 @@ function setupTests(test) {
|
||||
const processStderrWrite = process.stderr.write.bind(process.stderr);
|
||||
t.context.stderrWrite = processStderrWrite;
|
||||
process.stderr.write = wrapOutput(t.context);
|
||||
// Many tests modify environment variables. Take a copy now so that
|
||||
// We reset them after the test to keep tests independent of each other.
|
||||
// process.env only has strings fields, so a shallow copy is fine.
|
||||
t.context.env = {};
|
||||
Object.assign(process.env, t.context.env);
|
||||
});
|
||||
typedTest.afterEach.always(t => {
|
||||
// Restore stdout and stderr
|
||||
@@ -62,6 +67,8 @@ function setupTests(test) {
|
||||
}
|
||||
// Undo any modifications made by sinon
|
||||
sinon_1.default.restore();
|
||||
// Undo any modifications to the env
|
||||
process.env = t.context.env;
|
||||
});
|
||||
}
|
||||
exports.setupTests = setupTests;
|
||||
|
||||
Reference in new issue
Block a user