An ESLint plugin that enforces restrictions on Playwright APIs to ensure compatibility with Catchpoint's testing environment.
This plugin provides two custom ESLint rules:
no-restricted-catchpoint-playwright-imports- Prevents importing specific Playwright types that are not supported in Catchpoint testsno-restricted-catchpoint-playwright-properties- Prevents using specific page and browser properties that are not supported in Catchpoint tests
npm install eslint-plugin-catchpoint-playwright --save-devThis plugin supports:
- ESLint v7.x, v8.x, v9.x
- Node.js 14+
For the new flat config format in ESLint 9+:
// eslint.config.js
import catchpointPlaywright from 'eslint-plugin-catchpoint-playwright';
export default [
{
plugins: {
'catchpoint-playwright': catchpointPlaywright
},
rules: {
...catchpointPlaywright.configs['flat/recommended'].rules
}
}
];For traditional .eslintrc.* configuration files:
{
"plugins": ["catchpoint-playwright"],
"extends": ["plugin:catchpoint-playwright/recommended"]
}Or in .eslintrc.js:
module.exports = {
plugins: ['catchpoint-playwright'],
extends: ['plugin:catchpoint-playwright/recommended']
};You can also configure individual rules:
{
"plugins": ["catchpoint-playwright"],
"rules": {
"catchpoint-playwright/no-restricted-catchpoint-playwright-imports": "error",
"catchpoint-playwright/no-restricted-catchpoint-playwright-properties": "error"
}
}Prevents importing the following types from @playwright/test as they are not supported in Catchpoint tests:
BrowserBrowserContextBrowserServerBrowserType
❌ Invalid:
import { Browser, BrowserContext } from '@playwright/test';✅ Valid:
import { test, expect, Page } from '@playwright/test';Prevents using the following page and browser properties that are not supported in Catchpoint tests:
Page properties:
addInitScript()close()pdf()routeFromHAR()screenshot()setDefaultNavigationTimeout()setDefaultTimeout()videoworkerscontext
Browser properties:
newContext()
❌ Invalid:
await page.screenshot();
await page.close();
const context = browser.newContext();✅ Valid:
await page.goto('https://example.com');
await page.click('button');
await page.fill('input', 'value');Here's a complete example of a Catchpoint-compatible Playwright test:
import { test, expect } from '@playwright/test';
test('example test', async ({ page }) => {
// ✅ Supported operations
await page.goto('https://example.com');
await page.click('button#submit');
await page.fill('input[name="username"]', 'testuser');
const title = await page.title();
expect(title).toBe('Example Page');
// ❌ These would trigger ESLint errors:
// await page.screenshot(); // Not supported in Catchpoint
// await page.close(); // Not supported in Catchpoint
});This project uses:
- TypeScript for type safety
- Vitest for testing
- ESLint for code quality
npm testnpm run buildMIT
© 2025 - Jabran Rafique