testing
Helpers for testing programs that use the driver without a real Moodle, imported from
@falkenslab/moodle-driver/testing: a fake site served inside a browser context, made-up grading
panel HTML, and a browser manager that launches nothing.
Classes
| Class | Description |
|---|---|
| ServiceFailure | Thrown by a fake service to answer with Moodle's exception errorcode. |
Interfaces
| Interface | Description |
|---|---|
| FakeMoodleState | What the fake Moodle serves (serveFakeMoodle): the test sets it up and may change it while it runs (log someone in, change the sesskey); the fake records what it served in it. |
Variables
| Variable | Description |
|---|---|
| PANEL | A grader panel reduced to its submission status table, as Moodle 5.2 renders it: online text with a summary and a full block, a short online text with only a summary, files, and comments. Made up; no real submission. |
| SITE | The fake Moodle's URL: the site URL to give the functions under test. |
Functions
| Function | Description |
|---|---|
| fakeBrowserManager | A browser manager that never launches anything, with these methods instead. |
| launchTestBrowser | The first browser that launches headless: the system's Edge or Chrome, or Playwright's own Chromium (the test container, npm run test:docker); undefined skips the tests that need one. |
| moodlePage | A Moodle page reduced to what the driver reads: the body class, M.cfg (wwwroot, sesskey, userId, and contextid when given), the logout link in the user menu and the page heading, as Moodle 5.2 renders them. |
| serveFakeMoodle | Serves a fake Moodle at SITE in context: logged out, every page is the login page, as with Moodle's forced login (served in place: Playwright doesn't route the request after a redirect it fulfilled, confirmed empirically); state.user logs someone in. lib/ajax/service.php answers like Moodle's, exceptions included. |