openedx / openedx/frontend-base
TypeError undefined EnvironmentTypes.TEST on site.config.test.ts
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 4
- Forks
- 13
- Avg merge
- 3h 21m
- Merged PRs (30d)
- 10
Description
When running Jest tests, the EnvironmentTypes.TEST property is undefined, causing test failures during module loading. This occurs because the test configuration file site.config.test.tsx tries to access EnvironmentTypes.TEST before the module is properly loaded by Jest. This problem happens with some specific tests, not all the unit tests faces this error.
TypeError: Cannot read properties of undefined (reading 'TEST')
9 | logoutUrl: 'http://localhost:8000/logout',
> 10 | environment: EnvironmentTypes.TEST,
This workaround fixes the issue: environment: EnvironmentTypes.TEST ?? 'test', but it is needed to investigate why this is happening, this problem was observed during conversion frontend-app-account to frontend-base and while creating the new mfe for the instructor dashboard.
Some ideas on what can be happening:
- Configuration File Problem: The
site.config.test.tsxfile tries to accessEnvironmentTypes.TEST, but during Jest execution, theEnvironmentTypesobject is undefined or not properly loaded from the @openedx/frontend-base package. - Module Loading Order: Jest loads modules in a specific order, and sometimes the
EnvironmentTypesexport isn't available when the config file tries to use it.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with site.config.test.tsx and the Jest module-loading path around EnvironmentTypes from @openedx/frontend-base. Run the affected Jest tests, including cases observed during the frontend-app-account conversion and instructor dashboard work, and compare them with tests that load successfully. Done means the relevant tests load without EnvironmentTypes.TEST being undefined and the cause is understood rather than masked by the fallback.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- frontend, testing-qa
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100