Commit b8c7ead
fix(axe): the axe runner could never resolve @playwright/test (#338)
The runner is executed by absolute path from `${GITHUB_WORKSPACE}/gates/`
while the packages it needs are installed into
`server/apps/<app>/node_modules`. CommonJS resolves a module's own
`require` calls by walking up from the directory of the ENTRY FILE, not
from the process cwd, and those two paths are siblings — so the walk
never reaches the app's node_modules and `require('@playwright/test')`
throws MODULE_NOT_FOUND on the first repo that ever opted in.
That is docudesk#423: `enable-axe: true`, Playwright green, 82 e2e tests
passed, and then the axe step died on `Cannot find module
'@playwright/test'` — a failure with nothing to do with accessibility.
The step above it printed `@axe-core/playwright resolved.` on the same
run. It used `node -e`, which resolves from the cwd the step had just
`cd`-ed into, so it answered a question nobody asked: it measured
whether the package was on disk, never whether the runner could reach
it. It would have printed the same line on every future break of this
kind.
Two changes, one root cause:
* `NODE_PATH="${PWD}/node_modules"` on the runner invocation. NODE_PATH
is a global fallback consulted regardless of where the entry file
sits, which is exactly the property the cross-tree layout needs.
* the control now resolves through `createRequire` anchored ON THE
RUNNER, and checks both `@axe-core/playwright` and `@playwright/test`.
It therefore fails precisely when the runner would.
Measured on a reconstruction of the runner's real layout, with the
actual `axe-run.cjs`:
runner, no NODE_PATH -> Error: Cannot find module '@playwright/test'
runner, NODE_PATH set -> ::error::axe-runner: AXE_BASE_URL is empty.
old control -> PASS in both arms (this is the defect)
new probe, no NODE_PATH-> exit 1, MODULE_NOT_FOUND
new probe, NODE_PATH -> PASS
The second line is the proof: the runner gets past resolution and
reaches its own env validation. The third is why this went unseen.
Both `run:` blocks stay far under the ~20 KB per-step limit that made
this workflow unresolvable fleet-wide (2.1 KB and 2.6 KB).
Co-authored-by: Ruben van der Linde <juan.claude@conduction.nl>1 parent 78d882a commit b8c7ead
1 file changed
Lines changed: 46 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2888 | 2888 | | |
2889 | 2889 | | |
2890 | 2890 | | |
2891 | | - | |
| 2891 | + | |
| 2892 | + | |
| 2893 | + | |
| 2894 | + | |
| 2895 | + | |
| 2896 | + | |
| 2897 | + | |
| 2898 | + | |
| 2899 | + | |
| 2900 | + | |
| 2901 | + | |
| 2902 | + | |
| 2903 | + | |
| 2904 | + | |
| 2905 | + | |
| 2906 | + | |
| 2907 | + | |
| 2908 | + | |
| 2909 | + | |
| 2910 | + | |
| 2911 | + | |
| 2912 | + | |
| 2913 | + | |
| 2914 | + | |
| 2915 | + | |
| 2916 | + | |
| 2917 | + | |
| 2918 | + | |
| 2919 | + | |
| 2920 | + | |
| 2921 | + | |
| 2922 | + | |
| 2923 | + | |
| 2924 | + | |
| 2925 | + | |
| 2926 | + | |
| 2927 | + | |
| 2928 | + | |
| 2929 | + | |
2892 | 2930 | | |
2893 | 2931 | | |
2894 | 2932 | | |
| |||
2942 | 2980 | | |
2943 | 2981 | | |
2944 | 2982 | | |
| 2983 | + | |
| 2984 | + | |
| 2985 | + | |
| 2986 | + | |
| 2987 | + | |
| 2988 | + | |
| 2989 | + | |
2945 | 2990 | | |
2946 | 2991 | | |
2947 | 2992 | | |
| |||
0 commit comments