From 33a978a246fc42568f80aad07d3fcdc8a971c48e Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Wed, 1 Nov 2023 14:12:20 +0100 Subject: [PATCH] Ensure credentials.get stub is restored after tests --- .../@node-red/runtime/lib/flows/Flow_spec.js | 24 ++++--------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/test/unit/@node-red/runtime/lib/flows/Flow_spec.js b/test/unit/@node-red/runtime/lib/flows/Flow_spec.js index 61cee1f99..8406a01b7 100644 --- a/test/unit/@node-red/runtime/lib/flows/Flow_spec.js +++ b/test/unit/@node-red/runtime/lib/flows/Flow_spec.js @@ -1237,11 +1237,12 @@ describe('Flow', function() { }) describe("#env", function () { + afterEach(() => { + delete process.env.V0; + delete process.env.V1; + credentials.get.restore?.() + }) it("can instantiate a node with environment variable property values of group and tab", async function () { - after(function() { - delete process.env.V0; - delete process.env.V1; - }) process.env.V0 = "gv0"; process.env.V1 = "gv1"; process.env.V3 = "gv3"; @@ -1285,10 +1286,6 @@ describe('Flow', function() { }); it("can access environment variable property using $parent", async function () { - after(function() { - delete process.env.V0; - delete process.env.V1; - }) process.env.V0 = "gv0"; process.env.V1 = "gv1"; var config = flowUtils.parseConfig([ @@ -1323,9 +1320,6 @@ describe('Flow', function() { }); it("can define environment variable using JSONata", async function () { - after(function() { - delete process.env.V0; - }) var config = flowUtils.parseConfig([ {id:"t1",type:"tab",env:[ {"name": "V0", value: "1+2", type: "jsonata"} @@ -1348,9 +1342,6 @@ describe('Flow', function() { }); it("can access global environment variables defined as JSONata values", async function () { - after(function() { - delete process.env.V0; - }) var config = flowUtils.parseConfig([ {id:"t1",type:"tab",env:[ {"name": "V0", value: "1+2", type: "jsonata"} @@ -1372,11 +1363,6 @@ describe('Flow', function() { await flow.stop() }); it("global flow can access global-config defined environment variables", async function () { - after(function() { - delete process.env.V0; - credentials.get.restore() - }) - sinon.stub(credentials,"get").callsFake(function(id) { if (id === 'gc') { return { map: { GC_CRED: 'gc_cred' }}