Jest examples
These examples use Jest throughout. Start with the Jest 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 Jest
Puppeteer has no test runner of its own; its end-to-end suites run on Jest through the jest-puppeteer preset, which gives the tests a page and browser, and expect(page) matchers:
Excerpt: js
// e2e/order-ticket.e2e.js
describe('order ticket', () => {
beforeEach(async () => {
await page.goto(`${BASE_URL}/trade/AAPL`);
});
// ...
it.each([
['0', 'Quantity must be at least 1'],
['-5', 'Quantity must be at least 1'],
['1000001', 'Quantity is above the 1,000,000 share limit'],
])('rejects a quantity of %s', async (quantity, message) => {sh
npx test-inventory "e2e/**/*.e2e.js" --framework jest --output inventory.jsonThe preset only sets up the browser, so the scan reads the file as any Jest file, with no warning about it:
json
{
"fullName": "order ticket > rejects a quantity of %s",
"caseCount": 3,
"tags": ["e2e/order-ticket"],
"timeout": 30000,
"timeoutSource": "config"
}Next
- Jest configuration and limits.
- Query recipes: filter by state, tags and other fields.
- All framework guides: scan another runner in the same project.