Skip to content

MDL-88812 [docs] add JavaScript unit testing guide for React components#1603

Merged
andrewnicols merged 1 commit into
moodle:mainfrom
meirzamoodle:MDL-88812_docs
Jun 8, 2026
Merged

MDL-88812 [docs] add JavaScript unit testing guide for React components#1603
andrewnicols merged 1 commit into
moodle:mainfrom
meirzamoodle:MDL-88812_docs

Conversation

@meirzamoodle

Copy link
Copy Markdown
Contributor

Adds docs/guides/javascript/react/testing.md covering:

  • Running tests with npm test and grunt jsconfig pretest dependency
  • Project structure: jest.config.js, tsconfig.jest.json, .jest/globalSetup.ts
  • Where to place test files (/esm/tests//*.test.{ts,tsx})
  • Mocking AMD modules with mockAmdModule() and the ESM-layer testing pattern
  • Mocking language strings with mockString() and the default fallback behaviour
  • CommonJS mode rationale (no --experimental-vm-modules required)
  • core/amd coverage exclusion
  • Module path alias resolution
  • CI integration

Also updates the React index page to reference the new testing guide.

@netlify

netlify Bot commented Jun 2, 2026

Copy link
Copy Markdown

Deploy Preview for moodledevdocs ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit d32e222
🔍 Latest deploy log https://app.netlify.com/projects/moodledevdocs/deploys/6a263a01ece4e80008dd2e97
😎 Deploy Preview https://deploy-preview-1603--moodledevdocs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

Comment thread docs/guides/javascript/react/testing.md Outdated
Comment thread docs/guides/javascript/react/testing.md Outdated
Comment thread docs/guides/javascript/react/testing.md Outdated
Comment thread docs/guides/javascript/react/testing.md
Comment thread docs/guides/javascript/react/testing.md
Comment thread docs/guides/javascript/react/testing.md Outdated
Comment thread docs/guides/javascript/react/testing.md Outdated
Comment thread docs/guides/javascript/react/testing.md Outdated
Comment thread docs/guides/javascript/react/testing.md Outdated
Comment thread docs/guides/javascript/react/testing.md
@meirzamoodle meirzamoodle force-pushed the MDL-88812_docs branch 6 times, most recently from 739e6a5 to b8677b5 Compare June 8, 2026 02:48
@meirzamoodle

Copy link
Copy Markdown
Contributor Author

Hi, @andrewnicols. All suggestions have been resolved.

Adds docs/guides/javascript/react/testing.md covering:
- Running tests with npm test, single-file patterns, and coverage collection
- Where to place test files (**/esm/tests/**/*.test.{ts,tsx}) with nested directory examples
- Writing a basic test using describe/it/expect with ts-jest and jsdom
- Mocking AMD modules with mockAmdModule() and the ESM-layer testing pattern
- Mocking language strings with mockString() and the default fallback behaviour
- Module path alias resolution via tsconfig.aliases.json
- CI integration

Also updates the React index page to reference the new testing guide.
@andrewnicols andrewnicols added this pull request to the merge queue Jun 8, 2026
Merged via the queue into moodle:main with commit 8e855d0 Jun 8, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants