From 562e24af4e4bdc865afe20160dbc2b1d04db79e7 Mon Sep 17 00:00:00 2001 From: Jason Wesson Date: Thu, 30 Nov 2023 22:49:18 +0000 Subject: [PATCH] doc: add comments around how to set up env.config.js and testing with Jest --- example.env.config.js | 15 +++++++++++++++ src/setupTest.jsx | 17 +++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/example.env.config.js b/example.env.config.js index 6fd893ed9..ee2ebf32d 100644 --- a/example.env.config.js +++ b/example.env.config.js @@ -1,3 +1,18 @@ +/* +Learner Dashboard is now able to handle JS-based configuration! + +Until a later release, the .env.* files will still be included in this repo. + +Note: having both .env and env.config.js files will follow a predictable order +frontend-platform's getConfig loads configuration: +- .env file config +- optional handlers (commonly used to merge MFE-specific config in via additional process.env variables) +- env.config.js file config +- runtime config + +Any env vars needed for Jest Snapshot to pass can be mocked in ./src/setupTest.jsx +*/ + module.exports = { NODE_ENV: 'development', NODE_PATH: './src', diff --git a/src/setupTest.jsx b/src/setupTest.jsx index 2ac2d1b29..7a31cbedf 100755 --- a/src/setupTest.jsx +++ b/src/setupTest.jsx @@ -67,6 +67,23 @@ jest.mock('@edx/frontend-platform/i18n', () => { }; }); +/* +When .env.test is removed, uncomment the env vars below and add any environment variables for testing with Jest + +Context: Snapshot is not currently not set up to be able to parse the environment variables in env.config.js +*/ + +// jest.mock('@edx/frontend-platform', () => ({ +// getConfig: jest.fn(() => ({ +// LMS_BASE_URL: 'http://localhost:18000', +// LOGOUT_URL: 'http://localhost:18000/logout', +// LOGO_URL: 'https://edx-cdn.org/v3/default/logo.svg', +// MARKETING_SITE_BASE_URL: 'http://localhost:18000', +// SUPPORT_URL: 'http://localhost:18000/support', +// OPTIMIZELY_FULL_STACK_SDK_KEY: 'SDK Key', +// })), +// })); + jest.mock('@edx/paragon', () => jest.requireActual('testUtils').mockNestedComponents({ Alert: { Heading: 'Alert.Heading',