feat: split test:pw into per-suite scripts (path-analyser, request-validation)#25
Merged
Conversation
Generated Playwright suites use ESM constructs (e.g. `import.meta.url` in
`support/seeding.ts`) but their materialized package.json did not declare
`"type": "module"`. Running `npm run test:pw` from the workspace root
(where the parent `path-analyser/package.json` is itself ESM) caused
Playwright/Node to load the transpiled output ambiguously and surface:
ReferenceError: exports is not defined in ES module scope
at support/seeding.ts:3
Add `"type": "module"` to both template package.json files so the
materialized suites unambiguously declare their module format and match the
ESM source they ship.
Affected templates:
- path-analyser/templates/package.json
- request-validation/templates/package.json
Snapshot regenerated; all 49 vitest tests pass; verified end-to-end with
`npx playwright test ...` in the materialized suite.
The regression baseline previously pinned `specRef: "main"`, which caused the upstream-spec hash check (`tests/regression/spec-pin.setup.ts`) to fail every time camunda/camunda's `main` advanced — even though the snapshot itself was unchanged. Reviewers saw an opaque drift signal that required a no-op snapshot bump on each rebase. Pin `specRef` to commit `2b2b962a312b86586ade7547d513783371db32a2` (the SHA the current snapshot was captured against; `expectedSpecHash` is unchanged, confirming the pin is content-equivalent to the previous baseline). This requires `camunda-schema-bundler@^2.1.0`, which adds raw-SHA support to `fetchSpec` (camunda/camunda-schema-bundler#22). Bump the dep accordingly and document the SHA-pin convention in spec-pin.json's `$comment`.
1ab3098 to
ad4ca60
Compare
…anifest CI for PR #24 failed with: Pipeline output drifted from snapshot. Missing (1): - path-analyser/dist/generated-tests/test-results/.last-run.json The snapshot was captured locally after a Playwright run, which writes `test-results/.last-run.json` into the generated-tests tree. CI never runs Playwright before the snapshot test, so the file is absent and the regression test fails. Same class of defect would also affect `node_modules/` (left over from local `npm install` inside a generated suite) and `playwright-report/`. Filter all three out of `buildManifest()` so the manifest reflects only generator output, not runtime artifacts. Both the snapshot writer and the regression test reuse this function, so the filter applies on both sides. Regenerated manifest: 413 -> 412 files (the dropped entry is the playwright last-run marker).
…lidation) Previously `npm run test:pw` only ran the path-analyser positive suite; the request-validation negative suite had no root-level runner and was only reachable by cd-ing into `request-validation/generated/` and installing deps locally (which then triggered the "Requiring @playwright/test second time" duplicate-load error). New scripts: - `test:pw:path-analyser` — positive scenarios only - `test:pw:request-validation` — negative request-validation only - `test:pw` — sequential composite of the two `test:pw:request-validation` re-uses the materialized `request-validation/generated/playwright.config.ts` (testDir `.`, testMatch `**/*.spec.ts`), driven from root deps so no nested `npm install` is required. `testsuite:observe:run` now invokes `test:pw:path-analyser` explicitly because the runtime-observation pipeline only instruments the positive suite. README quick start and the available-scripts table updated to document the three options. Snapshot regenerated.
ad4ca60 to
b85ee65
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Answer to the original question
Before:
npm run test:pwran only the path-analyser positive suite. The request-validation negative suite had no root-level runner.After:
npm run test:pw:path-analysernpm run test:pw:request-validationnpm run test:pwImplementation
test:pw:request-validationreuses the materializedrequest-validation/generated/playwright.config.ts(itstestDir: '.'+testMatch: '**/*.spec.ts'already match what we want), driven from root deps \u2014 no nestednpm installrequired.testsuite:observe:runnow invokestest:pw:path-analyserexplicitly because the runtime-observation pipeline only instruments the positive suite.Verification
npx vitest run\u2014 49/49 passnpm run test:pw:path-analyser\u2014 488 passed locallynpm run test:pw:request-validation\u2014 58 ran (2 expected auth-related failures against my local cluster)