Skip to content

liferay/liferay-portal / .claude/skills/pr-check

pr-check

Verified

Check that a PR is ready to be sent for review.

FileKindSize
SKILL.mdskill md36.5 KB
find_modules.shexecutablescript1.4 KB
references/testing.mdmarkdown5.4 KB
select_paths.shexecutablescript2.2 KB
select_validations.shexecutablescript1.1 KB
validations/branch/bean-param-util-getter.mdmarkdown6.6 KB
validations/branch/bnd-content.mdmarkdown15.2 KB
validations/branch/bnd-dsannotations-options.mdmarkdown9.1 KB
validations/branch/cache-field-usage.mdmarkdown13.9 KB
validations/branch/concurrent-mapper-hash-map-usage.mdmarkdown7.5 KB
validations/branch/html-escaping.mdmarkdown2.6 KB
validations/branch/pr-reviewer.mdmarkdown6.6 KB
validations/branch/redundant-assert-message.mdmarkdown13.5 KB
validations/branch/required-configuration-policy.mdmarkdown7.9 KB
validations/branch/service-holder-usage.mdmarkdown8.3 KB
validations/branch/service-registration.mdmarkdown3.7 KB
validations/branch/source-format.mdmarkdown4.1 KB
validations/branch/startup-sync-usage.mdmarkdown10.6 KB
validations/branch/transaction-usage.mdmarkdown4.0 KB
validations/branch/unused-project-dependencies.mdmarkdown18.5 KB
validations/portal/baseline.mdmarkdown14.0 KB
validations/portal/cross-module-compile.mdmarkdown7.9 KB
validations/portal/full-portal-build.mdmarkdown1.4 KB
validations/portal/go-generate.mdmarkdown2.8 KB
validations/portal/go-source-format.mdmarkdown1.9 KB
validations/portal/helm-unit-test-order.mdmarkdown1.4 KB
validations/portal/instance-wrapper-build.mdmarkdown656 B
validations/portal/java-unit-test.mdmarkdown6.7 KB
validations/portal/javascript-unit-test.mdmarkdown7.7 KB
validations/portal/module-registration.mdmarkdown7.8 KB
validations/portal/per-module-compile.mdmarkdown10.4 KB
validations/portal/portlet-title.mdmarkdown1.1 KB
validations/portal/poshi-syntax.mdmarkdown336 B
validations/portal/pql-validation.mdmarkdown516 B
validations/portal/rest-builder.mdmarkdown938 B
validations/portal/service-builder.mdmarkdown1.6 KB
validations/portal/structural-smoke.mdmarkdown3.9 KB
validations/portal/theme-build.mdmarkdown2.0 KB
validations/workspaces/generated-file.mdmarkdown2.5 KB
validations/workspaces/source-format.mdmarkdown2.0 KB
validations/workspaces/workspace-compile.mdmarkdown1.8 KB
validations/workspaces/workspace-java-unit-test.mdmarkdown1.7 KB
validations/workspaces/workspace-javascript-unit-test.mdmarkdown1.9 KB

validations/portal/javascript-unit-test.md

View on GitHub
# JavaScript Unit Tests

Runs the Jest suites of the modules a change touches. A lockfile or a `package.json` dependency change counts too, since a dependency pin can affect any code path.

## Match

`^modules/.+\.(js|jsx|mjs|cjs|ts|tsx)$|^modules/.+/(package\.json|package-lock\.json|yarn\.lock)$ &! ^modules/test/playwright/`

## Command

Take the changed modules from the changed paths. A module qualifies when one of its changed paths is a `.js`, `.jsx`, `.mjs`, `.cjs`, `.ts`, or `.tsx` source, or its `package.json`, `package-lock.json`, or `yarn.lock`. The module is the nearest ancestor directory holding a `package.json`, and never `modules` itself, whose `package.json` is the workspace root rather than a module. Shared tooling that sits there belongs to [per-module-compile.md](per-module-compile.md), which builds it but runs no suite against it.

A source change with no behavior intent, such as a rename, formatting, a comment, or JSDoc, does not qualify a module, and a `package.json` qualifies it only when the change touches `dependencies`, `devDependencies`, `scripts.build`, or `scripts.test`. A lockfile qualifies it whatever changed, since a transitive pin can affect any code path. When no module qualifies, run nothing and report **NOT APPLICABLE**, naming the changes as surface only.

`modules/test/playwright` is never a qualifying module either. Its `test` script runs Playwright rather than Jest, so it has no Jest suite to judge.

`modules/node-scripts.config.js` is the exception worth naming. Its `imports` map decides which package files every module's build exposes, so a change there can break the suites of modules the diff never touched while no rule above selects anything. When the diff changes it, run the suites of the modules whose entry in that map the diff altered.

```bash
bash "${SKILL_DIR}/select_paths.sh" "${MERGE_BASE}" "${VALIDATION_FILE}"
```

Run each selected module's **full Jest suite**; do not select individual specs by name. Run the modules one at a time, never in parallel, since Jest already uses every core and parallel suites time out against each other:

```bash
(cd <module> && npm test)
```

With no `test` script there is no suite, so record that and continue to the sweeps below rather than exiting.

**Cross module consumer snapshots.** The changed module's own suite does not cover a snapshot stored in a *consumer* module. When another module declares the changed module by name in its `dependencies` or `devDependencies`, also run those consumers. Do not read `"private": true` as ruling this out, since Liferay modules depend on each other by bare name with `"*"` and a private module is still a workspace dependency.

List the consumers in a fixed order. A consumer is a module under `modules`, other than the changed module, whose `package.json` names the changed module's package `name` in `dependencies` or `devDependencies` and declares a `test` script. Put first the consumers that have a file under their `test` directory that imports or mocks the package, then the rest, and sort each group by module path, as `LC_ALL=C sort` does. A file imports or mocks the package when it has `from`, `require(`, `import(`, or `jest.mock(` followed by a quote and the package name, then either the closing quote or a `/`.

Run the full suite of each of the first 8. When the list is longer, qualify the verdict with how many of the listed consumers ran, such as `PASS (8 of 103 consumers)`.

**Stale stub lists.** A module that stubs a shared package family for Jest keeps its own copy of the stub list, so adding a package to that family leaves every copy stale.

Sweep only when the addition changes what **other** modules resolve. A dependency pinned to a version the workspace root cannot satisfy installs under the changed module's own `node_modules`, so every other module still resolves what it resolved before and none of them can have gone stale. Compare the added range against the version `modules/yarn.lock` resolves for that package. Read the lockfile rather than `modules/node_modules`, which is gitignored and absent on a fresh clone. When the locked version satisfies the range, or the package is not locked at all, the resolution is shared and the sweep is worth running. Otherwise say the addition is module local and skip it.

When it does apply, take each third party package the diff adds to the changed module's `dependencies`, use its npm scope, or the package name itself when it is unscoped, and run every module whose `jest-setup.config.js` or `jest-setup.config.ts` mocks anything in that scope rather than the added package itself, since the modules still missing it are exactly the ones the sweep is for. Keep a module that already mocks the added package in the sweep too, since the selection is by scope. Do not cap this set. It is bounded in practice by how few modules carry a `jest-setup.config`, so report its size rather than assuming that holds.

That file is the only stub list this sweep reads. A module can also stub through a `__mocks__` directory, through `moduleNameMapper` in its `package.json`, or through `setupFilesAfterEnv`, and a stale list in any of those is invisible here.

**Oversized suites.** When a module's suite is large enough to blow the time budget, fall back to the specs under the module's `test` tree that name each changed source, plus every changed file in that tree, and note the reduced scope in the result. Match on the source's base name appearing in a spec path rather than on a `Foo.test.tsx` convention: this repository's `testMatch` is `${rootDir}/test/**/*.{js,ts,tsx}`, so specs look like `test/js/components/Answer.es.js` and carry no `.test.` infix, and searching for one selects nothing at all.

A suite that fails only on `Exceeded timeout of 5000 ms` may have lost a race for the CPU rather than failed, so rerun the failing specs of that module alone before judging, and judge from the rerun.

Decide PASS or FAIL from Jest's **`Test Suites:`** line, not from the exit status and not from the `Tests:` line. A suite that fails to load contributes no test case, so `Tests:` reports it as zero failures while the run exits nonzero, and reading `Tests:` alone passes a module whose suites never ran. `Test Suites: 6 failed, 20 passed` is a failure whatever `Tests:` says.

A module with no `test` script has no suite to judge and does not fail this validation.

When a suite fails, separate the two causes before charging it to the branch. Read the **frame that fails**, not every frame in the trace: an import of the added dependency can appear in the stack while the error is raised somewhere else entirely, in a file the diff never touched and reached through a module it never changed.

FAIL when the failing frame is in something the diff changed. When it is not, the module is already broken, so report **NOT VERIFIED** for it and name the error. This covers an assertion that fails as much as a suite that never loads, and the sweeps above are what make the distinction matter, since they deliberately run modules the diff never touched and a red test already sitting in one of them is not this branch's to answer for. Confirm it either way by resolving the import as the failing module would (`require.resolve` with that module's directory as `paths`), which shows whether the added dependency is even on the path that broke, and return the resolved path for every module that went red. `modules` is a yarn workspace, so a module with no local `node_modules` resolves from the workspace root and runs normally, and a genuine setup failure is a whole repository condition rather than a per module one.

## Checklist

Add one subitem per affected module:

```
- [ ] <module path>: full suite
```

## Time Estimate

~1 - 5 min per module suite. The oversized suite fallback caps larger ones.
receiving-code-reviewobra/superpowersUse when receiving code review feedback, before implementing suggestions, especially if feedback seems unclear or technically questionable - requires technical rigor and verification, not performative agreement or blind implementationStars: 322kUpdated Claude CodeCodexVerifiedInstall
requesting-code-reviewobra/superpowersUse when completing tasks, implementing major features, or before merging to verify work meets requirementsStars: 322kUpdated Claude CodeCodexVerifiedInstall
using-git-worktreesobra/superpowersUse when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated workspace exists via native tools or git worktree fallbackStars: 322kUpdated Claude CodeCodexVerifiedInstall
verification-before-completionobra/superpowersUse when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions alwaysStars: 322kUpdated Claude CodeCodexVerifiedInstall