From 80f0ba4abfa9737b33cc37b4ef33be88f80788f4 Mon Sep 17 00:00:00 2001 From: Naz Date: Thu, 17 Feb 2022 20:26:16 +0700 Subject: [PATCH] Improved WEBHOOK_SECRET initialization in tests refs https://github.com/TryGhost/Toolbox/issues/214 - Having to fill out `process.env` variables in tests is a frustrating developer experience. Test environment should be configured with smart defaults, so the developer writing test cases would modify variables like this only is special test cases. --- test/e2e-api/members/webhooks.test.js | 1 - test/utils/overrides.js | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/test/e2e-api/members/webhooks.test.js b/test/e2e-api/members/webhooks.test.js index c42b39c81c..5207bb6816 100644 --- a/test/e2e-api/members/webhooks.test.js +++ b/test/e2e-api/members/webhooks.test.js @@ -8,7 +8,6 @@ let adminAgent; describe('Members API', function () { before(async function () { - process.env.WEBHOOK_SECRET = 'pissoff'; // Weird - most of the mocks happen after getting the agent // but to mock stripe we want to fake the stripe keys in the settings. // And it's initialised at boot - so mocking it before diff --git a/test/utils/overrides.js b/test/utils/overrides.js index 0f572f5fbf..c65629f874 100644 --- a/test/utils/overrides.js +++ b/test/utils/overrides.js @@ -1,4 +1,5 @@ process.env.NODE_ENV = process.env.NODE_ENV || 'testing'; +process.env.WEBHOOK_SECRET = process.env.WEBHOOK_SECRET || 'TEST_STRIPE_WEBHOOK_SECRET'; require('../../core/server/overrides');