/
eup
/
khsm
Обзор
Документация
Войти
/
eup
/
khsm
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
verify_html_test.mjs
33 строки
1 KB
eup
Create: build_random_html_test.mjs, build_test.mjs, inspect_questions.mjs, verify_html_test.mjs, verify_test.mjs, Тест_КХСМ_рандом.html
07 июн 2026, 12:06
Верифицирован
07 июн 2026, 12:06
d2942e3
Код
Авторство
О чём код?
import fs from "node:fs/promises"; import vm from "node:vm"; const htmlPath = "C:/Users/egoru/Documents/Codex/2026-05-02/files-mentioned-by-the-user-xlsx/Тест_КХСМ_рандом.html"; const html = await fs.readFile(htmlPath, "utf8"); const bankMatch = html.match(/const QUESTION_BANK = (\[[\s\S]*?\]);\n\s*const LETTERS/); if (!bankMatch) throw new Error("QUESTION_BANK was not found in HTML."); const questions = vm.runInNewContext(bankMatch[1]); const badRows = questions.filter((item) => !item.question || !Array.isArray(item.options) || item.options.length !== 4 || item.options.some((option) => !option) || !["A", "B", "C", "D"].includes(item.answer) ); if (questions.length < 15) throw new Error(`Only ${questions.length} questions found.`); if (badRows.length > 0) throw new Error(`${badRows.length} malformed questions found.`); if (!html.includes("shuffle(QUESTION_BANK).slice(0, 15)")) { throw new Error("Random 15-question selection was not found."); } if (!html.includes("Правильных ответов:")) { throw new Error("Score output was not found."); } console.log(JSON.stringify({ htmlPath, questionCount: questions.length, sampleQuestion: questions[0].question, status: "ok", }, null, 2));