From 6b829d2551c6b90d1d7d67d46471d845083b1fff Mon Sep 17 00:00:00 2001 From: Scott Motte Date: Wed, 24 Jan 2024 10:34:01 -0800 Subject: [PATCH] demonstrate currently failing (pending) test. multiple env files should merge --- tests/test-config.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/test-config.js b/tests/test-config.js index 1a24c6bc..fc420476 100644 --- a/tests/test-config.js +++ b/tests/test-config.js @@ -41,6 +41,27 @@ t.test('takes two or more files in the array for path option', ct => { ct.end() }) +t.test('sets values from both .env.local and .env. first file key wins.', { skip: true }, ct => { + delete process.env.SINGLE_QUOTES + + const testPath = ['tests/.env.local', 'tests/.env'] + const env = dotenv.config({ path: testPath }) + + // in both files - first file wins (.env.local) + ct.equal(env.parsed.BASIC, 'local_basic') + ct.equal(process.env.BASIC, 'local_basic') + + // in .env.local only + ct.equal(env.parsed.LOCAL, 'local') + ct.equal(process.env.LOCAL, 'local') + + // in .env only + ct.equal(env.parsed.SINGLE_QUOTES, 'single_quotes') + ct.equal(process.env.SINGLE_QUOTES, 'single_quotes') + + ct.end() +}) + t.test('takes URL for path option', ct => { const envPath = path.resolve(__dirname, '.env') const fileUrl = new URL(`file://${envPath}`)