testaro 58.0.0 → 58.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +1 -360
  2. package/UPGRADES.md +1515 -0
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -965,366 +965,7 @@ As of 12 February 2024, upon the transfer of the repository ownership to CVS Hea
965
965
 
966
966
  ## Future work
967
967
 
968
- Future work on this project may include TypeScript conversion, conversion of Playwright testing to use Playwright Test, and any revisions necessary in order to permit this project to be containerized.
969
-
970
- ### TypeScript conversion
971
-
972
- Recommendations on 2025-09-23 from `gpt-5` via Cursor 1.6.35:
973
-
974
- **Question**
975
-
976
- What are the major decisions that will be required if this entire repository is converted from JavaScript to TypeScript?
977
-
978
- **Answer**
979
-
980
- I'll scan key files to understand the current setup (module system, scripts, dependencies) so I can tailor the TypeScript migration decisions to this repo’s specifics.
981
-
982
- I'll quickly scan for module patterns and JSON imports across the repo to tailor the TypeScript migration decisions (CJS vs ESM, JSON handling, dynamic requires).
983
-
984
- #### Major decisions for a full TypeScript migration
985
-
986
- - **Module system and runtime**
987
- - CommonJS vs ESM output (`module` = commonjs vs nodenext) and `package.json` `"type"` choice.
988
- - Whether to keep `require/exports` at runtime or rewrite to `import/export` in source.
989
- - `esModuleInterop`/`allowSyntheticDefaultImports` settings for interop.
990
-
991
- - **Build vs runtime execution**
992
- - Transpile-then-run (`tsc` to `dist/`) vs on-the-fly (`ts-node`/register) for all CLI executors in `validation/executors/` and top-level scripts.
993
- - If building, how to resolve runtime paths to forked workers (e.g., `procs/doTestAct`): compute `dist` paths, or use a loader.
994
-
995
- - **Pathing for child processes**
996
- - How `child_process.fork` targets compiled files (adjust `__dirname` usage, emit to predictable `outDir`, or use ts-node in children).
997
- - Consistent strategy for file URL handling (current `file://` normalization logic) post-build.
998
-
999
- - **Type strictness and tsconfig**
1000
- - Level of strictness (`strict`, `noImplicitAny`, `strictNullChecks`, `exactOptionalPropertyTypes`, `noUncheckedIndexedAccess`).
1001
- - Target and libs (`target` ES2020/ES2022; `lib` includes `ES2020`, `DOM` if needed for `page.evaluate` contexts).
1002
- - `moduleResolution` (`node`, `nodenext`, or `bundler`) and `resolveJsonModule` (only if you convert JSON imports from fs-read to imports).
1003
-
1004
- - **Data model design**
1005
- - Formal interfaces for `Job`, `Report`, `Act` (discriminated unions for `type` = `launch|test|url|wait|state|page|...`), and nested structures like `standardResult`, `jobData`, `toolTimes`.
1006
- - How much to type dynamic/mutable shapes (e.g., `report.jobData.*`, adding properties lazily) vs using `any`/`Partial`.
1007
- - Strategy for optional properties and progressive enrichment during execution.
1008
-
1009
- - **3rd‑party types and augmentations**
1010
- - Verify/choose type packages for `playwright`, `@siteimprove/alfa-*`, `axe-playwright`, `@qualweb/*`, `accessibility-checker`, `playwright-dompath`, `pixelmatch`. Plan fallbacks if defs are missing.
1011
- - Decide on module augmentation vs casting for custom fields (e.g., `page.browserID` assignment requires augmenting `playwright.Page` or casting).
1012
-
1013
- - **Dynamic loading patterns**
1014
- - `tests/testaro.js` dynamically requires rule modules by filename; decide to:
1015
- - keep dynamic `require` (typed as `unknown`/`any`), or
1016
- - replace with a typed registry/factory, or
1017
- - use dynamic `import()` with explicit result typing.
1018
- - Same decision for runtime JSON rule loading vs typed imports.
1019
-
1020
- - **JSON rule and data typing**
1021
- - Define interfaces for JSON rule files in `testaro/*.json` and job property JSON under `validation/tests/jobProperties/`.
1022
- - Whether to keep fs-based JSON reads (runtime-validated) or switch to typed imports using `resolveJsonModule`.
1023
-
1024
- - **Node/DOM boundary typing**
1025
- - How to type `page.evaluate` payloads and element handles; utility helpers like `textOf`, `getLocatorData`, `boxOf` should have precise generics vs `any`.
1026
- - Decide whether to include `DOM` lib globally or rely on Playwright types and narrow evaluate functions.
1027
-
1028
- - **Error and result typing**
1029
- - Standardize error codes/messages (e.g., `'status429'`, `'badRedirection'`, numeric codes from children) into a typed union.
1030
- - Time-limit handling and messaging types for per-rule timeouts.
1031
-
1032
- - **Project layout and outputs**
1033
- - Where compiled files live (`dist/` mirroring current tree) and which directories are included/excluded (`node_modules`, `temp/`, `validation/jobs/**`, `validation/tests/targets/**`).
1034
- - Whether to keep `.js` under `testaro/` alongside `.json` or convert all rule JS to `.ts`.
1035
-
1036
- - **Tooling**
1037
- - ESLint to TS config (`@typescript-eslint/*`, parser, rules), what to enforce/relax during migration.
1038
- - Incremental checking plan (`allowJs`, `checkJs`, JSDoc types) vs big‑bang conversion.
1039
- - `skipLibCheck` policy for faster builds vs stricter dependency checks.
1040
-
1041
- - **Runtime compatibility and CI**
1042
- - Minimum Node version (current code uses `fs/promises`; align `target`/features accordingly).
1043
- - Update `npm` scripts to run compiled executors or ts-node variants; adjust `main`/exports fields.
1044
- - Update CI to compile, run validation suites, and publish artifacts if applicable.
1045
-
1046
- - **Performance and DX choices**
1047
- - Use of `tslib`/`importHelpers` to reduce output size.
1048
- - Source maps for debugging vs build speed.
1049
- - Build caching and watch mode for local dev across many small files.
1050
-
1051
- - **Public API typing**
1052
- - Surface types for externally used entry points like `run.js` (`doJob`, `launch`) if this is used as a library; decide on `.d.ts` emission and what is considered public.
1053
-
1054
- - **Gradual safety boundaries**
1055
- - Where to place `unknown`/`any` escapes (e.g., dynamic module results, process messages) and how to fence them with runtime guards to preserve correctness.
1056
-
1057
- - **Behavioral parity vs refactor**
1058
- - Whether to refactor opportunistically (e.g., replace dynamic exports, normalize act handling with discriminated unions) or preserve exact runtime semantics first and harden types later.
1059
-
1060
- - **Monorepo/external types scenario (if needed)**
1061
- - If `ibmOutput/` or other data folders need typings or should be excluded entirely from compilation.
1062
-
1063
- - **Licensing and headers**
1064
- - How to preserve license headers/comments during transpilation if that’s a requirement.
1065
-
1066
- - **Migration sequencing**
1067
- - Directory order (e.g., core `procs/` first, then `tests/`, then executors) and gate criteria to keep `validation` flows working throughout.
1068
-
1069
- - **Testing strategy**
1070
- - Decide on type-level tests and runtime regression checks for the many rules in `testaro/` to ensure no behavior drift.
1071
-
1072
- - **Non-standard patterns**
1073
- - Confirm approach for in-place mutation of Playwright elements (focus/check/click workflows) and timing helpers to remain compatible under TS’s stricter async typing.
1074
-
1075
- - **Distribution and consumers**
1076
- - If published, decide on dual CJS/ESM output and `exports` map for consumers; if internal CLI only, keep CJS for simplicity.
1077
-
1078
- - **Env/config handling**
1079
- - Typing for env vars (e.g., `DEBUG`, `WAITS`) and a strategy to centralize env parsing, optionally with a schema.
1080
-
1081
- - **File I/O and paths**
1082
- - Formalize types for file contents read/written (reports, JSON job files) and ensure atomicity/encoding assumptions are explicit.
1083
-
1084
- - **Automated code mods**
1085
- - Choose codemods for `require`→`import`, `exports.`→`export`, and add TSDoc/JSDoc scaffolding where helpful.
1086
-
1087
- - **Fallback for missing types**
1088
- - Policy for creating minimal `*.d.ts` shims vs pinning dependency versions that ship their own types.
1089
-
1090
- - **Security and sandboxing**
1091
- - Revisit `page.evaluate` usage to ensure types don’t mask unsafe patterns; possibly introduce typed helpers for CSP/nonce handling.
1092
-
1093
- - **Ownership and conventions**
1094
- - Naming, folder structure for types, and conventions (e.g., suffix `*Rule.ts` for testaro rules, `*Executor.ts` for executors).
1095
-
1096
- - **Performance budgets**
1097
- - Ensure TS doesn’t slow hot paths; decide on `transpileOnly` for dev and full type-check in CI.
1098
-
1099
- - **Docs**
1100
- - Whether to publish type-first docs for rules, job schema, and report schema.
1101
-
1102
- - **Binary compatibility and scripts**
1103
- - Shebang/CLI wrappers if any are added; adjust NPM scripts (`run`, `tests`, `dirWatch`, `netWatch`) to compiled targets.
1104
-
1105
- - **Source of truth for rule registry**
1106
- - Move from filesystem discovery/dynamic require to a typed registry or keep FS-based discovery and accept weaker typing there.
1107
-
1108
- - **Augmentation of global state**
1109
- - Approach for module-global mutable state (`browser`, `page`, `actIndex`, `actCount`) under TS (keep, or encapsulate for easier typing).
1110
-
1111
- - **Error codes and enums**
1112
- - Decide on enums/constants for error strings currently used ad hoc across modules.
1113
-
1114
- - **Back-compatibility**
1115
- - If external users rely on current JS entry points, decide on keeping JS shim files or major-version bump.
1116
-
1117
- - **CI artifacts**
1118
- - Whether to commit `dist/` for executors used by external systems (if any) or build on demand.
1119
-
1120
- - **Validation data**
1121
- - Type-checking and exclude patterns for large static trees under `validation/tests/targets/**`.
1122
-
1123
- - **Standardization pipeline**
1124
- - Strongly typing `standardize`, `identify`, `getLocatorData` interfaces to ensure the report format remains stable.
1125
-
1126
- - **Global configuration**
1127
- - Where to centralize tsconfig(s): single root vs per-folder `tsconfig.json` if executors or tests need different settings.
1128
-
1129
- - **Dev ergonomics**
1130
- - Editor/watch settings for auto-build and source maps to keep the current debugging/logging experience.
1131
-
1132
- - **Release management**
1133
- - Versioning strategy aligning the migration with a major release and a deprecation window for JS users.
1134
-
1135
- - **Repository hygiene**
1136
- - Git ignore updates for `dist/`, source maps, and generated typings; precommit checks for type errors.
1137
-
1138
- - **Incremental guardrails**
1139
- - Introduce `// TODO(ts):` backlog tags and thresholds (e.g., don’t merge if new `any`s added) to keep type quality from regressing.
1140
-
1141
- - **Performance of rule timeouts**
1142
- - Keep or parameterize the 15s per-rule timeout with typed config; ensure typings don’t accidentally widen timing types.
1143
-
1144
- - **Playwright context**
1145
- - Decide if `Page`/`BrowserContext` are passed through typed helpers rather than shared module state to improve type soundness.
1146
-
1147
- - **Logging**
1148
- - Strongly type logging interfaces and message formats (currently strings) if you want structured logs.
1149
-
1150
- - **Observability hooks**
1151
- - Type `tellServer` interface so message parameters are validated at compile time.
1152
-
1153
- - **Temporary directories and file lifecycle**
1154
- - Ensure typed guarantees for report temp file creation/deletion around `doActs`.
1155
-
1156
- - **Edge-case Node APIs**
1157
- - Keep `process.on('message')` and `fork` message contract typed (e.g., discriminated unions for IPC).
1158
-
1159
- - **Risk posture**
1160
- - Choose between maximal type safety (more refactor) vs minimal-change transpilation (faster migration, looser types).
1161
-
1162
- - **Team workflow**
1163
- - Coding standards for type annotations, error handling, and rule authoring templates (`data/template.js` → `.ts`).
1164
-
1165
- - **Documentation updates**
1166
- - Update `README.md` and contributor docs for TS build, scripts, and rule authoring in TS.
1167
-
1168
- - **License headers**
1169
- - Confirm TypeScript compiler preserves headers in output where needed.
1170
-
1171
- - **Binary assets**
1172
- - Decide on handling and typing for `ed11y/editoria11y.min.js`, `htmlcs/HTMLCS.js`, and `temp/engine/*.js` (likely exclude from TS).
1173
-
1174
- - **Validation executors**
1175
- - Whether to type and migrate `validation/**` (watchers, runners) now or later; they are part of the runtime entrypoints.
1176
-
1177
- - **Scripted searches**
1178
- - If any script relies on `.js` globbing, update to include `.ts` or compiled `.js` as appropriate.
1179
-
1180
- - **Monorepo split (optional)**
1181
- - Consider separating library (`procs/`, `testaro/`) from CLI/executors to simplify build and type boundaries.
1182
-
1183
- - **Release notes and migration guide**
1184
- - Communicate breaking changes (paths, module format, APIs) to downstream users.
1185
-
1186
- - **Contingency**
1187
- - Rollback plan if TS introduces runtime regressions; maintain a JS branch during transition.
1188
-
1189
- - **Ownership of generated types**
1190
- - Whether to emit `.d.ts` for public consumption and how to keep them in sync.
1191
-
1192
- - **Security posture**
1193
- - Type-narrow inputs to `page.evaluate` to reduce injection risks; consider runtime schema validation aligned with compile-time types.
1194
-
1195
- - **Consistency and naming**
1196
- - Normalize names (e.g., rule IDs, act types) in enums to prevent typo bugs now caught by types.
1197
-
1198
- - **Testing gates**
1199
- - Enforce typecheck in CI (noEmit + typecheck) and keep separate from build to catch type errors early.
1200
-
1201
- - **Performance tuning**
1202
- - `skipLibCheck` usage for speed in CI, and segment builds if needed.
1203
-
1204
- - **Dev dependency choices**
1205
- - Add and pin: `typescript`, `ts-node` (if used), `@types/node`, `@typescript-eslint/*`, `tslib`.
1206
-
1207
- - **Scaffolding**
1208
- - Provide a TS rule template replacing `data/template.js`.
1209
-
1210
- - **Migration approach**
1211
- - Big bang vs module-by-module with `allowJs`; define the cutover point for flipping scripts to compiled artifacts.
1212
-
1213
- - **Source map policy**
1214
- - Whether to emit for executors (useful for debugging) and how to ship them.
1215
-
1216
- - **Error handling consistency**
1217
- - Tighten thrown vs returned error patterns and type them across modules.
1218
-
1219
- - **API surfaces to freeze**
1220
- - Identify external-callable functions (e.g., `doJob`) and lock their types as public contracts.
1221
-
1222
- - **Coding ergonomics**
1223
- - Decide on utility types and helpers to avoid repeated broad `any`.
1224
-
1225
- - **CI matrix**
1226
- - If Node versions vary in your environments, decide on supported versions and align TS `target` and features.
1227
-
1228
- - **Sourcemap stack traces**
1229
- - Configure `source-map-support` if you need clean stack traces in production.
1230
-
1231
- - **Rule discovery**
1232
- - If you keep filesystem discovery of rules, define a typed manifest generator to bridge dynamic loading and static typing.
1233
-
1234
- - **Binary and non-TS code**
1235
- - Exclude third-party/minified JS from the TS pipeline; document it in `tsconfig.exclude`.
1236
-
1237
- - **Globbing and watch**
1238
- - Decide on watch-mode for dev across large tree and avoid compiling validation target fixtures.
1239
-
1240
- - **Optional refactors**
1241
- - Replace stringly-typed error/status codes with enums for compile-time checks.
1242
-
1243
- - **Docs for contributors**
1244
- - Update `CONTRIBUTING.md` to explain adding new rules/tests in TS.
1245
-
1246
- - **License and headers policy**
1247
- - Ensure headers are preserved via tsconfig `removeComments: false` (or custom tooling).
1248
-
1249
- - **Long-term maintenance**
1250
- - Plan for gradually increasing strictness and paying down `any`/casts.
1251
-
1252
- - **Ownership of types**
1253
- - Assign owners for core type packages (job/report schema) to prevent drift.
1254
-
1255
- - **Release cadence**
1256
- - Decide on a major version for TS cutover and soft-deprecate JS.
1257
-
1258
- - **Verification runs**
1259
- - Run the existing `validation` flows pre/post migration to assert parity.
1260
-
1261
- - **Scripting updates**
1262
- - Update NPM scripts to call `node dist/...` or `ts-node ...` consistently.
1263
-
1264
- - **Formatting**
1265
- - Decide on Prettier integration for TS files.
1266
-
1267
- - **Path aliases**
1268
- - Whether to introduce TS path mapping (e.g., `@procs/*`) and align runtime with `tsconfig-paths` if used.
1269
-
1270
- - **Type exposure for consumers**
1271
- - If this is used as a library, add `types` in `package.json` and consider dual-emit CJS/ESM with an `exports` map.
1272
-
1273
- - **Internal logging contracts**
1274
- - Give `tellServer` a typed param object instead of loosely concatenated query strings.
1275
-
1276
- - **IPC contracts**
1277
- - Type the message payloads between parent and forked child (act results, error codes) as discriminated unions.
1278
-
1279
- - **Rule authoring ergonomics**
1280
- - Provide typed helpers (`init`, `report`, `simplify`) signatures and ensure rule modules stay small and consistent.
1281
-
1282
- - **Binary deps (Playwright)**
1283
- - Decide if Playwright version pins need to change for type stability.
1284
-
1285
- - **Local dev**
1286
- - Editor/tsserver performance considerations; exclude large static trees to keep TS fast.
1287
-
1288
- - **Guarding dynamic text operations**
1289
- - Tight typing for text processing helpers (`debloat`, `textOf`) to reduce nullability issues.
1290
-
1291
- - **Backward-compatible shims**
1292
- - If external systems call JS entrypoints, add thin JS shims that `require` built outputs.
1293
-
1294
- - **Risk acceptance**
1295
- - Explicitly document areas that remain `any` for practicality (dynamic rule loading, external tool outputs).
1296
-
1297
- - **Ownership and review**
1298
- - Establish code owners for type changes spanning modules (`procs/`, `tests/`, `validation/`).
1299
-
1300
- - **Documentation of schemas**
1301
- - Publish the job/report JSON schema alongside TS types to keep runtime validation aligned.
1302
-
1303
- - **SLA for migration**
1304
- - Timeline and checkpoints (compile, typecheck clean, parity runs, strictness uplift).
1305
-
1306
- - **Final cutover**
1307
- - Switch scripts to compiled artifacts, remove `allowJs`, and enforce TS-only in CI.
1308
-
1309
- - **Post-cutover cleanups**
1310
- - Remove unused JS files, codemod leftovers, and deprecated helpers.
1311
-
1312
- - **Observability**
1313
- - Optional: typed structured logs to replace ad hoc `console.log` parsing in CI.
1314
-
1315
- - **Security review**
1316
- - Review `page.evaluate` and dynamic inputs under strict types; add guards where types reveal risks.
1317
-
1318
- - **Team training**
1319
- - Align on TS patterns (narrowing, discriminated unions, module augmentation).
1320
-
1321
- - **Performance validation**
1322
- - Ensure no regressions in tool time limits and process orchestration after build step insertion.
1323
-
1324
- - **Long-term benefits**
1325
- - Decide which parts gain the most from rich typing first (job/act schema, rule registry, Playwright helpers).
1326
-
1327
- - Converted the repo’s needs into concrete decision points covering module format, build/run, tsconfig, domain typing, dynamic loading, child-process pathing, 3rd‑party types, and CI/publishing impacts.
968
+ Future work on this project is being considered. Strategic recommendations for such work are recorded in the `UPGRADES.md` file.
1328
969
 
1329
970
  ## Etymology
1330
971