From 32013299750b066ffcb13441ebc73cac544500da Mon Sep 17 00:00:00 2001 From: j-mendez Date: Wed, 27 Sep 2023 10:08:17 -0400 Subject: [PATCH] test(full): add all runners --- kayle/package.json | 1 + kayle/tests/full.ts | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 kayle/tests/full.ts diff --git a/kayle/package.json b/kayle/package.json index b36ec5d..ddd2968 100644 --- a/kayle/package.json +++ b/kayle/package.json @@ -46,6 +46,7 @@ "test:puppeteer:extension": "npm run compile:test && yarn build:extension && node _tests/tests/extension.js", "test:puppeteer:tables": "npm run compile:test && node _tests/tests/tables.js", "test:puppeteer:clips": "npm run compile:test && node _tests/tests/clips.js", + "test:full": "npm run compile:test && node _tests/tests/full.js", "test:lint": "node build/lint.js", "test:unit:unique-selector": "npm run compile:test && node _tests/tests/unit/unique-selector.js", "publish": "yarn prepare && yarn npm publish" diff --git a/kayle/tests/full.ts b/kayle/tests/full.ts new file mode 100644 index 0000000..255cd9d --- /dev/null +++ b/kayle/tests/full.ts @@ -0,0 +1,40 @@ +// run fast_axe, fast_htmlcs, and ace +import assert from "assert"; +import puppeteer from "puppeteer"; +import { Standard, kayle } from "kayle"; +import { drakeMock } from "./mocks/html-mock"; +import { performance } from "perf_hooks"; + +(async () => { + const browser = await puppeteer.launch({ headless: "new" }); + const page = await browser.newPage(); + if (process.env.LOG_ENABLED) { + page.on("console", (msg) => console.log("PAGE LOG:", msg.text())); + } + const startTime = performance.now(); + const { issues, pageUrl, documentTitle, meta, automateable } = await kayle({ + page, + browser, + runners: ["htmlcs", "axe", "ace"], + includeWarnings: true, + html: drakeMock, + standard: Standard.WCAG2AA, + origin: "https://www.drake.com", // origin is the fake url in place of the raw content + }); + const nextTime = performance.now() - startTime; + + console.log(meta); + console.log(automateable); + console.log("time took", nextTime); + + // valid list + assert(Array.isArray(issues)); + assert(meta.errorCount === 88); + assert(meta.warningCount === 51); + assert(meta.accessScore === 30); + + assert(typeof pageUrl === "string"); + assert(typeof documentTitle === "string"); + + await browser.close(); +})();