Browser tests and mock apps
Verify lifecycle and CSP in a browser and generate test providers from contracts.
Requires WU CLI 1.2.0 and WU Framework 4.0.0 for application APIs. Check wu --version and the project dependencies.
Node and browser tests
wu test
wu test --watch
npm install --save-dev @playwright/test
npx playwright install chromium
wu test --browser --csp strict --trusted-types --json
Without --browser, wu test runs node --test and forwards remaining arguments and output. With --browser, it switches to Chromium lifecycle verification: it reads configured apps, starts development when needed and checks mounting, updates, hiding, recovery and cleanup. Exit is 0 for success, 1 for a failed check and 2 for setup failure.
| Option | Usage |
|---|---|
--url <origin> |
Uses an existing server. |
--port <port> |
Server startup port; default 3999. |
--only <app> |
Filters apps by name; repeatable. |
--cycles <n> |
From 2 to 20; default 2. |
--timeout <ms> |
From 1000 to 120000; default 30000. |
--csp <mode> |
scripts by default, strict or off. |
--trusted-types |
Adds Trusted Types directives. |
--channel <name> |
Chromium channel; also WU_BROWSER_CHANNEL. |
--headed, --verbose, --json |
Visible window, detailed output or JSON report. |
Generate a mock provider
Save this descriptor as counter.json in the workspace:
{ "name": "counter", "version": "1.1.0", "methods": {
"double": { "input": { "type": "number" }, "output": { "type": "number" } }
} }
wu mock counter.json --name counter-mock --dir mf-counter-mock --json
wu install
wu dev
wu mock generates a runnable microapp, schema-valid responses and its wu.config.json entry. Edit src/samples.js to change data; the app displays methods and calls. The default name derives from the service with a -mock suffix; --dir chooses the directory. --force allows replacing an existing destination, so review its contents first.
Generation exits with 0; invalid contracts, arguments or projects produce 2. A mock supports development against a contract; it does not implement real business logic. A lifecycle suite also does not replace functional screen tests. Verify both before publishing.