diff --git a/tests/action.test.ts b/tests/action.test.ts index 832765198..3b3e2f2db 100644 --- a/tests/action.test.ts +++ b/tests/action.test.ts @@ -450,6 +450,7 @@ describe('github-tag-action', () => { beforeEach(() => { jest.clearAllMocks(); setBranch('prerelease'); + loadDefaultInputs(); setInput('pre_release_branches', 'prerelease'); }); diff --git a/tests/helper.test.ts b/tests/helper.test.ts index d56b50be5..bb33c0a61 100644 --- a/tests/helper.test.ts +++ b/tests/helper.test.ts @@ -26,6 +26,13 @@ export function setInputs(map: { [key: string]: string }) { Object.keys(map).forEach((key) => setInput(key, map[key])); } +export function resetInputs(map: { [key: string]: string }) { + Object.keys(process.env) + .filter(k => k.startsWith("INPUT_")) + .forEach(k => delete process.env[k]); + Object.keys(map).forEach((key) => setInput(key, map[key])); +} + export function loadDefaultInputs() { const actionYaml = fs.readFileSync( path.join(process.cwd(), 'action.yml'), @@ -40,7 +47,7 @@ export function loadDefaultInputs() { (obj, key) => ({ ...obj, [key]: actionJson['inputs'][key].default }), {} ); - setInputs(defaultInputs); + resetInputs(defaultInputs); } // Don't know how to have this file only for test but not have 'tsc' complain. So I made it a test file...