Mocha examples
These examples use Mocha throughout. Start with the Mocha guide for installation, your first scan and framework-specific limits. Each example shows a project's file layout; adjust its globs to your own suite. Scanning reads the source without running tests or starting a browser.
Puppeteer on Mocha
On Mocha, a Puppeteer suite usually starts the browser in root hooks, which a file in the config's require exports as mochaHooks, and keeps the page on the test's context:
Excerpt: js
// e2e/order-ticket.e2e.js
describe('order ticket', function () {
beforeEach(async function () {
await this.page.goto(`${BASE_URL}/trade/AAPL`);
});
// ...
it('shows the order in the blotter', async function () {
this.timeout(60_000);sh
npx test-inventory "e2e/**/*.e2e.js" --framework mocha --output inventory.jsonThe root hooks aren't counted in hooks, but the file that exports them is one of each test's dependencies, so dependencyHash changes when it does:
json
{
"fullName": "order ticket > shows the order in the blotter",
"timeout": 60000,
"timeoutSource": "test",
"dependencies": [".mocharc.json", "e2e/browser.js", "e2e/order-ticket.e2e.js"]
}Next
- Mocha configuration and limits.
- Query recipes: filter by state, tags and other fields.
- All framework guides: scan another runner in the same project.