openedx / openedx/frontend-base

TypeError undefined EnvironmentTypes.TEST on site.config.test.ts

Open
#108 0 comments 0 reactions 0 assignees View on GitHub

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.tsx file tries to access EnvironmentTypes.TEST, but during Jest execution, the EnvironmentTypes object 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 EnvironmentTypes export isn't available when the config file tries to use it.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.