chore: Generate visual test definitions barrel file automatically - #4998
chore: Generate visual test definitions barrel file automatically#4998jperals wants to merge 5 commits into
Conversation
1cc0ea3 to
d399841
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4998 +/- ##
=======================================
Coverage 97.66% 97.66%
=======================================
Files 960 960
Lines 31368 31368
Branches 11593 11593
=======================================
Hits 30637 30637
Misses 685 685
Partials 46 46 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
🟡 Changes recommended
Critical export regressions must be fixed, and the contributor workflow documentation should be updated.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Automates generation of the visual test definitions barrel during the test-definitions build.
Changes:
- Removes the manually maintained barrel.
- Adds JavaScript and TypeScript barrel generation.
- Runs generation after compilation and registers the task.
File summaries
| File | Summary |
|---|---|
test/definitions/index.ts |
Removes the manual barrel file. |
build-tools/tasks/test-definitions.js |
Chains compilation with generation; contributor documentation should be updated. |
build-tools/tasks/index.js |
Registers the generator task. |
build-tools/tasks/generate-test-definitions-index.js |
Generates grouped exports; must preserve dropdownAlignment and the existing allSuites export. |
Review details
- Files reviewed: 4/4 changed files
- Comments generated: 3
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| componentLines.push(`const ${exportName} = [${suites}];`); | ||
| componentLines.push(`exports.${exportName} = ${exportName};`); |
| // Compile the definitions, then generate the barrel index (lib/test-definitions/index.js) | ||
| // from the files in test/definitions/visual so it does not need to be maintained by hand. | ||
| module.exports = series(compile, generateTestDefinitionsIndex); |
There was a problem hiding this comment.
🟡 Changes recommended
Preserve the existing grouped exports and allSuites to avoid a breaking API change.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
- Files reviewed: 5/5 changed files
- Comments generated: 1
- Review effort level: Lite
| function generateIndexJs(definitions) { | ||
| const lines = definitions.map(file => { | ||
| const exportName = toCamelCase(file); | ||
| return `exports.${exportName} = require('./visual/${file}').default;`; |
Co-authored-by: Maximilian Schoell <mxschll@users.noreply.github.com>
Description
Autogenerate the barrel file
test/definitions/index.tsso that in order to add new visual regression tests we only need to add files totest/definitions/visual, and there is no risk of forgetting to updatetest/definitions/index.ts.How has this been tested?
Review checklist
The following items are to be evaluated by the author(s) and the reviewer(s).
Correctness
CONTRIBUTING.md.CONTRIBUTING.md.Security
checkSafeUrlfunction.Testing
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.