Skip to main content

create-test

Create or update test cases for a Zotero translator by running it against live URLs and capturing the output.

Informations de source

Dépôt
zotero/translators
Dernière activité de la source
10 août 2026 à 22:55
Langue détectée de SKILL.md
anglais
Étoiles
1 721
Forks
932

Options d'installation

Le prompt qui vérifie d'abord la source est sélectionné par défaut. Vous pouvez passer à une commande directe ou télécharger une copie locale.

Vérifiez les fichiers source

Lisez SKILL.md et les fichiers associés affichés par SkillsMP avant de décider de l'installer.

Affichage de SKILL.md

SKILL.md
Instructions source · Aperçu en lecture seule
name
create-test
description
Create or update test cases for a Zotero translator by running it against live URLs and capturing the output.
## How test cases work Test cases are embedded at the end of each translator file between `/** BEGIN TEST CASES **/` and `/** END TEST CASES **/`. They look like JS but **the content is strict JSON** — double-quoted keys, no trailing commas, no comments, no single quotes. The linter enforces this. ```js /** BEGIN TEST CASES **/ var testCases = [ { "type": "web", "url": "https://example.com/article/123", "items": [ { "itemType": "journalArticle", "title": "Example Article", ... } ] } ] /** END TEST CASES **/ ``` ## Creating test cases The tool runs the translator, captures its output, and writes the test case JSON directly into the file. Do NOT hand-write test case item objects. ### Web ``` node .bin/create-test.mjs "<translator filename>" --url "<url>" ``` ### Search ``` node .bin/create-test.mjs "<translator filename>" --search '{"DOI":"10.1234/example"}' ``` ### Import ``` node .bin/create-test.mjs "<translator filename>" --input "<import data>" ``` ### Export Export tests are not supported by the automated test runner. Test export translators manually. ## Options - `--no-write`: Preview the captured test case without modifying the file. - `--json`: Output structured JSON. - `--headed`: Open a visible browser. Required for sites behind Cloudflare or a similar anti-bot wall, which refuse headless Chrome outright. ## Guidelines - Include at least one single-item test and one `"multiple"` test (if supported). - Use stable URLs unlikely to change (DOI-based, permalinks, archived content). - Always use this tool to generate test cases. Never write test case items by hand — the tool ensures the JSON matches what the translator actually produces. - If you need to update a test case after changing translator code, re-run the tool for that URL. Replace the old test case entry with the new output.
Voir sur GitHub