---
url: https://huldoser.github.io/test-inventory/frameworks/mocha-examples.md
description: Scan Puppeteer suites running on Mocha with test-inventory.
---

# Mocha examples

These examples use Mocha throughout. Start with the [Mocha guide](/frameworks/mocha) 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:

```js excerpt
// 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.json
```

The 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](/frameworks/mocha#configuration-and-limits).
* [Query recipes](/guide/recipes): filter by state, tags and other fields.
* [All framework guides](/frameworks/): scan another runner in the same project.
