E2E OCR Rules

SkillDocs & knowledge

E2E OCR assertions with Tesseract.js for canvas-only UI such as PDF pages in Cypress page objects. Use when asserting canvas-only E2E text with OCR.

Use E2E OCR Rules in Claude, ChatGPT or Ahel Desktop

Free. Sign in, add E2E OCR Rules and connect your AI. About a minute.

Also: Claude Code · Cursor · Codex

Then ask your AI: use the E2E OCR Rules skill

Details

Instructions available. Your AI can read the instructions. Execution depends on the setup they require.

Add Ahel to your AI once: Claude, ChatGPT, Cursor, Claude Code or Codex. Then ask it to use this.

E2E OCR RulesStart free

What this skill tells your AI

The instructions your AI receives, as published by nerds-odd-e/doughnut in .agents/skills/e2e-ocr/SKILL.md and read by Ahel’s review.

Use this skill when asserting text that is not in the DOM, such as PDF content drawn only to <canvas>. Keep OCR in test infrastructure, not product code.

Tesseract Setup

  • Use tesseract.js, a root devDependency, for canvas-only assertions via cy.task.
  • Register a Node task in e2e_test/config/common.ts.
  • The task should call tesseract.js createWorker and recognize on image bytes, such as base64 PNG without the data:image/png;base64, prefix.
  • Example task name: ocrCanvasImage.

Language Data

  • Commit e2e_test/tesseract/eng.traineddata uncompressed.
  • Pass langPath and cachePath to that directory when creating the worker.
  • This prevents Tesseract from writing eng.traineddata to the repo root. Root-level traineddata files are gitignored as a fallback.

Page Object Pattern

  • Wait until the canvas has real ink before OCR. Sampling getImageData for dark pixels is better than checking only non-zero alpha, because an empty white fill can still have alpha.
  • Export with toDataURL("image/png").
  • Strip the data URL prefix.
  • Use cy.task(..., { timeout: ... }) for slow OCR.
  • Assert the returned string contains the expected substring with a clear message.
  • Reference: e2e_test/start/pageObjects/bookReadingPage.ts, from expectPdfBeginningVisible through expectCurrentPage(1).expectVisibleOCRContains.

Signals

GitHub stars
49
Forks
72
Last commit
Oct 2026
Advanced
Item type
skill
Key
e2e-ocr
Source
github.com/nerds-odd-e/doughnut