{"id":48924,"library":"playwright-ajv-schema-validator","title":"Playwright AJV Schema Validator","description":"A Playwright plugin for API response schema validation against JSON schemas, OpenAPI 3, and Swagger 2 documents. Current version 1.0.2, stable release with monthly minor updates. Built on Ajv validator. Key differentiators: integrates with pw-api-plugin and standard Playwright API requests, provides clear error reporting in HTML reports and Trace Viewer, supports environment variables to disable validation or toggle logging. No breaking changes noted yet.","status":"active","version":"1.0.2","language":"javascript","source_language":"en","source_url":"https://github.com/sclavijosuero/playwright-ajv-schema-validator","tags":["javascript","plugin","playwright","ajv","schema","validator","json","typescript"],"install":[{"cmd":"npm install playwright-ajv-schema-validator","lang":"bash","label":"npm"},{"cmd":"yarn add playwright-ajv-schema-validator","lang":"bash","label":"yarn"},{"cmd":"pnpm add playwright-ajv-schema-validator","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency: requires Playwright for API request handling and test runner","package":"playwright","optional":false},{"reason":"Used for JSON schema validation engine","package":"ajv","optional":false},{"reason":"Core validation logic wrapper","package":"core-ajv-schema-validator","optional":false}],"imports":[{"note":"Named export; use ESM only as package is ESM-first. CommonJS require may fail.","wrong":"const validateSchema = require('playwright-ajv-schema-validator');","symbol":"validateSchema","correct":"import { validateSchema } from 'playwright-ajv-schema-validator';"},{"note":"Default export only available as ESM; not recommended as the primary export is validateSchema.","wrong":"const playwrightAjvSchemaValidator = require('playwright-ajv-schema-validator').default;","symbol":"default","correct":"import playwrightAjvSchemaValidator from 'playwright-ajv-schema-validator';"},{"note":"TypeScript types are included; import type for type-checking.","wrong":null,"symbol":"validateSchema type","correct":"import type { ValidateSchemaFn } from 'playwright-ajv-schema-validator';"}],"quickstart":{"code":"import { test, expect } from '@playwright/test';\nimport { validateSchema } from 'playwright-ajv-schema-validator';\nimport path from 'path';\nimport fs from 'fs';\n\nconst schemaPath = path.resolve(__dirname, 'schemas', 'user.json');\nconst schema = JSON.parse(fs.readFileSync(schemaPath, 'utf8'));\n\ntest('POST /users response schema validation', async ({ request, fixtures }) => {\n  const response = await request.post('https://api.example.com/users', {\n    data: { name: 'John' }\n  });\n  const data = await response.json();\n  const validationResult = validateSchema(fixtures, data, schema);\n  expect(validationResult.passed).toBeTruthy();\n  if (!validationResult.passed) {\n    console.error('Schema errors:', validationResult.errors);\n  }\n});","lang":"typescript","description":"Shows how to validate a Playwright API response against a JSON schema using validateSchema function."},"warnings":[{"fix":"Provide the test's fixtures argument, or use an empty object {} if not needed.","message":"validateSchema requires 'fixtures' object; passing undefined or null will cause runtime error","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use dot-notation or bracket notation JSONPath, e.g., '$.data.users'.","message":"The 'path' parameter in validateSchema is for JSONPath, not file path. Common confusion with file paths.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Set process.env.DISABLE_SCHEMA_VALIDATION = 'true' before tests.","message":"Environment variable DISABLE_SCHEMA_VALIDATION must be set to 'true' (string) to disable; boolean true won't work in Playwright config","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'1.0.2':24 '2':20 '3':17 'ajv':2,33,75 'api':9,41,46 'break':68 'built':31 'chang':69 'clear':49 'current':22 'differenti':36 'disabl':62 'document':21 'environ':59 'error':50 'html':53 'integr':37 'javascript':72 'json':14,78 'key':35 'log':66 'minor':29 'month':28 'note':70 'openapi':16 'playwright':1,6,45,74 'plugin':7,42,73 'provid':48 'pw':40 'pw-api-plugin':39 'releas':26 'report':51,54 'request':47 'respons':10 'schema':3,11,15,76 'stabl':25 'standard':44 'support':58 'swagger':19 'toggl':65 'trace':56 'typescript':79 'updat':30 'valid':4,12,34,63,77 'variabl':60 'version':23 'viewer':57 'yet':71","created_at":"2026-06-07T16:59:09.712526+00:00","updated_at":"2026-06-07T16:59:09.712526+00:00","problems":[{"fix":"Pass the first argument of your test callback, which is the 'fixtures' object provided by Playwright.","cause":"The 'fixtures' object passed to validateSchema is not the Playwright test fixtures but an incorrect object","error":"TypeError: fixtures.testInfo is not a function"},{"fix":"Ensure package is installed: npm install playwright-ajv-schema-validator. If using CJS, switch to ESM or use dynamic import.","cause":"Package not installed or not resolvable due to ESM/CJS mismatch","error":"Cannot find module 'playwright-ajv-schema-validator'"},{"fix":"Ensure schema is a parsed JSON object, not a string or undefined.","cause":"The 'schema' argument passed to validateSchema is not a valid JSON schema object","error":"Error: schema must be an object or array"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/sclavijosuero/playwright-ajv-schema-validator#readme","github":"https://github.com/sclavijosuero/playwright-ajv-schema-validator","docs":null,"changelog":null,"pypi":null,"npm":"playwright-ajv-schema-validator","openapi_spec":null,"status_page":null,"smithery":null,"categories":["testing"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}