test: extract shared test helpers into @local/testkit - #1915
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
Adds a shared internal test helper package (@local/testkit) and migrates existing unit/rule tests to use it, keeping #/testing/helpers as backward-compatible re-export shims.
Changes:
- Introduces
.pkgs/testkitwith shared parsing, linter harness, RuleTester setup, and scope-context helpers. - Replaces
testing/helpers/*implementations with re-exports from@local/testkit. - Updates multiple package/plugin tests and docs to use the shared helpers; wires workspace deps accordingly.
Reviewed changes
Copilot reviewed 45 out of 46 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| testing/helpers/rule-tester.ts | Re-export RuleTester helpers from @local/testkit. |
| testing/helpers/lint-runner.ts | Re-export ESLint runner helper from @local/testkit. |
| testing/helpers/get-fixtures-root-dir.ts | Re-export fixtures root resolver from @local/testkit. |
| plugins/eslint-plugin-react-jsx/src/rules/no-key-after-spread/no-key-after-spread.spec.ts | Uses createRuleTesterForJsxEmit instead of bespoke RuleTester setup. |
| plugins/eslint-plugin-react-debug/src/rules/jsx/jsx.spec.ts | Uses createRuleTesterForJsxEmit instead of bespoke RuleTester setup. |
| packages/var/src/resolve.test.ts | Migrates custom linter harness to runInRule. |
| packages/var/src/resolve-import-source.test.ts | Migrates parsing/fixtures to parseCode + getFixturesRootDir. |
| packages/var/src/resolve-enclosing-assignment-target.test.ts | Migrates parsing to parseCode. |
| packages/var/src/is-value-equal.test.ts | Migrates custom linter harness to runInRule. |
| packages/var/src/is-assignment-target-equal.test.ts | Migrates custom linter harness to runInRule. |
| packages/var/src/compute-object-type.test.ts | Migrates custom linter harness to runInRule. |
| packages/var/package.json | Adds @local/testkit devDependency. |
| packages/jsx/src/text.test.ts | Migrates JSX node capture to getNodeInRule. |
| packages/jsx/src/element.test.ts | Migrates JSX node capture to getNodeInRule. |
| packages/jsx/src/children.test.ts | Migrates JSX node capture to getNodeInRule. |
| packages/jsx/src/attribute-value.test.ts | Migrates context+node capture to getNodeInRule. |
| packages/jsx/src/attribute-find.test.ts | Migrates context+node capture to getNodeInRule. |
| packages/jsx/package.json | Adds @local/testkit devDependency. |
| packages/core/src/jsx.test.ts | Migrates parsing/scope-context construction to parseCode + createScopeContext. |
| packages/core/src/hook.test.ts | Migrates parsing to parseCode. |
| packages/core/src/hook-collector.test.ts | Migrates collector harness to runCollector. |
| packages/core/src/function.test.ts | Migrates parsing to parseCode. |
| packages/core/src/function-component.test.ts | Migrates parsing to parseCode. |
| packages/core/src/function-component-collector.test.ts | Migrates collector harness to runCollector. |
| packages/core/src/class.test.ts | Migrates parsing to parseCode. |
| packages/core/src/class-component.test.ts | Migrates parsing to parseCode. |
| packages/core/package.json | Adds @local/testkit devDependency. |
| packages/ast/src/traverse.test.ts | Migrates parsing to parseCode. |
| packages/ast/src/extract.test.ts | Migrates node extraction to getFirstNodeOfType. |
| packages/ast/src/compare.test.ts | Migrates node collection to collectNodes. |
| packages/ast/src/check.test.ts | Migrates helpers to @local/testkit (fixtures + node extraction). |
| packages/ast/package.json | Adds @local/testkit devDependency. |
| docs/rule-implementation-patterns.md | Documents new shared helpers and preferred usage patterns. |
| docs/repo-path-aliases.md | Documents @local/testkit vs #/testing/helpers guidance. |
| .pkgs/testkit/package.json | Declares new internal @local/testkit package and exports. |
| .pkgs/testkit/tsconfig.json | TypeScript config for the new package. |
| .pkgs/testkit/tsl.config.ts | TSL config for the new package. |
| .pkgs/testkit/src/index.ts | Barrel exports for testkit helpers. |
| .pkgs/testkit/src/fixtures.ts | Implements fixtures root resolution for testkit. |
| .pkgs/testkit/src/parse.ts | Adds parseCode + node collection helpers. |
| .pkgs/testkit/src/linter.ts | Adds runInRule, getNodeInRule, runCollector harnesses. |
| .pkgs/testkit/src/mock-context.ts | Adds createScopeContext helper for scope-aware contexts. |
| .pkgs/testkit/src/rule-tester.ts | Centralizes RuleTester + vitest wiring and JSX-emit helpers. |
| .pkgs/testkit/src/lint-runner.ts | Adds lintWithConfig helper implementation. |
| package.json | Adds workspace dependency on @local/testkit. |
| pnpm-lock.yaml | Locks new workspace package and dependency graph updates. |
Files not reviewed (1)
- pnpm-lock.yaml: Generated file
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Add .pkgs/testkit (@local/testkit, source-only internal package) with parseCode/collectNodes/getFirstNodeOfType, runInRule/getNodeInRule/ runCollector, createScopeContext, and createRuleTesterForJsxEmit - Turn testing/helpers into re-export shims for backward compatibility - Migrate 24 package unit tests and 2 rule specs to the shared kit, removing per-file copy-pasted harness boilerplate - Document the new helpers in docs/rule-implementation-patterns.md and docs/repo-path-aliases.md
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
|
Warning Review the following alerts detected in dependencies. According to your organization's Security Policy, it is recommended to resolve "Warn" alerts. Learn more about Socket for GitHub.
|
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: REL1CX <solarflarex@qq.com>
Update "[ ]" to "[x]" to check a box
What kind of change does this PR introduce?
Check at least one. If you are introducing a new binding, you must reference an issue where this binding has been proposed, discussed and approved by the maintainers.
Does this PR introduce a breaking change?
If yes, please describe the impact and migration path for existing applications in an attached issue.
Checklist
fix: remove a typo, closes #___, #___)Other information