Skip to content

Record case ids with plune ids

plune ids writes the Plune case id of every Playwright test that names none into plune/ids.json, a map from the test’s path-title key to its case id. Test files are not edited. Playwright is the only framework it understands.

{
"tests/cart.spec.ts#cart#adds an item": "7b0e5c3a-2f41-4d8e-a6b9-91c4d3e8f052"
}

It is a dry run by default: it prints what it would add. --write writes the file.

The tests come from playwright test --list --reporter=json, as for plune verify. For each test:

  • A test that already names an id (a PluneId annotation or @P<id> in its title) or already has an entry in the file is left alone.
  • A test whose case Plune already holds, matched by its path-title key, gets an entry.
  • A test with no case yet is listed and skipped. Plune creates the case on the first run.

Entries are only added. An existing entry is never overwritten, and an entry for a test no longer in the code is kept and listed. Keys are sorted, so diffs stay small, and a second run writes nothing.

A file that is not valid JSON, or not an object of strings, is refused with exit code 2 and left untouched.

The Playwright reporter reads plune/ids.json when it resolves a test’s case. An entry names the case after the PluneId annotation, @P<id> in the title and a metadata attachment id, and before the playwright-id and path-title keys.

  • The file is looked up as plune/ids.json under the directory the run starts in.
  • The reporter option idsFile or the environment variable PLUNE_IDS_FILE sets another path.
  • A missing file is skipped. An invalid one is warned about once and ignored.
FlagEffect
--writeWrite the file. Without it nothing is written.
--file <path>The mapfile. Default plune/ids.json.
--from <file>Read a saved playwright test --list --reporter=json instead of running Playwright.
--playwright-config <path>Passed to playwright test --config.
--jsonPrint the report as JSON instead of text.

Like pull and push, it needs a saved login or PLUNE_TOKEN.

As for plune verify.

CodeWhen
0Success, including a dry run.
1The platform could not be reached or answered with an error.
2Not logged in, a rejected token, or a file that cannot be read or is invalid.