feat: support rstest in testing library#2328
Conversation
commit ff2cb92 Merge: b2d5322 f66e319 Author: Yiming Li <yimingli.cs@gmail.com> Date: Wed Aug 20 16:36:09 2025 +0800 Merge remote-tracking branch 'gh/main' into feat/rltl-rstest commit b2d5322 Merge: 44fbd57 f0d483c Author: Yiming Li <yimingli.cs@gmail.com> Date: Wed Aug 20 16:24:41 2025 +0800 Merge remote-tracking branch 'gh/main' into feat/rltl-rstest commit 44fbd57 Author: Yiming Li <yimingli.cs@gmail.com> Date: Thu Aug 14 11:18:57 2025 +0800 fix: rstest css module classname is diff from vitest commit 2825c3c Merge: 24cd0a2 fcec513 Author: Yiming Li <yimingli.cs@gmail.com> Date: Thu Aug 14 10:20:05 2025 +0800 Merge remote-tracking branch 'gh/main' into feat/rltl-rstest commit 24cd0a2 Merge: 41f71f1 cb6d23c Author: Yiming Li <yimingli.cs@gmail.com> Date: Wed Aug 13 19:32:36 2025 +0800 Merge remote-tracking branch 'gh/main' into feat/rltl-rstest commit 41f71f1 Author: Yiming Li <yimingli.cs@gmail.com> Date: Mon Aug 11 14:47:06 2025 +0800 fix: update testing cases commit 1a18210 Author: Yiming Li <yimingli.cs@gmail.com> Date: Mon Aug 11 12:23:48 2025 +0800 chore: remove process.env['DEBUG'] commit 0c38300 Merge: 1f51a70 05b0096 Author: Yiming Li <yimingli.cs@gmail.com> Date: Mon Aug 11 12:18:52 2025 +0800 Merge remote-tracking branch 'gh/main' into feat/rltl-rstest commit 1f51a70 Author: Yiming Li <yimingli.cs@gmail.com> Date: Wed Aug 6 21:03:31 2025 +0800 fix: snapshot commit 76872a4 Merge: 095bc28 0eeae9d Author: Yiming Li <yimingli.cs@gmail.com> Date: Wed Aug 6 21:00:19 2025 +0800 Merge remote-tracking branch 'gh/main' into feat/rltl-rstest commit 095bc28 Author: Yiming Li <yimingli.cs@gmail.com> Date: Wed Aug 6 20:56:49 2025 +0800 feat: remove enableDefine and use lynx.config to define __ALOG__ commit 9d8bd7c Author: Yiming Li <yimingli.cs@gmail.com> Date: Wed Aug 6 20:53:33 2025 +0800 feat: use getRspeedyAPI and remove applyStubRspeedyAPI commit b898c19 Merge: e884c07 6baeb9f Author: Yiming Li <yimingli.cs@gmail.com> Date: Wed Aug 6 15:47:53 2025 +0800 Merge remote-tracking branch 'gh/main' into feat/rltl-rstest commit e884c07 Author: Yiming Li <yimingli.cs@gmail.com> Date: Mon Aug 4 10:44:41 2025 +0800 fix: remove test.only commit b5567fa Merge: 34bd921 8e6321a Author: Yiming Li <yimingli.cs@gmail.com> Date: Mon Aug 4 10:45:30 2025 +0800 Merge branch 'main' into feat/rltl-rstest commit 34bd921 Author: Yiming Li <yimingli.cs@gmail.com> Date: Sat Aug 2 00:21:42 2025 +0800 feat: add test cases for callerName: rstest commit 37ccc68 Author: Yiming Li <yimingli.cs@gmail.com> Date: Fri Aug 1 23:51:31 2025 +0800 feat: add applyStubRspeedyAPI commit 37cd1c8 Merge: 8863f55 22ca433 Author: Yiming Li <yimingli.cs@gmail.com> Date: Fri Aug 1 22:45:43 2025 +0800 Merge remote-tracking branch 'gh/main' into feat/rltl-rstest commit 8863f55 Author: Yiming Li <yimingli.cs@gmail.com> Date: Fri Aug 1 22:08:53 2025 +0800 fix: cr commit cf78e1a Author: Yiming Li <yimingli.cs@gmail.com> Date: Wed Jul 30 17:51:42 2025 +0800 chore: changeset commit 0d4e0c9 Merge: bfdebd0 a4ee4fd Author: Yiming Li <yimingli.cs@gmail.com> Date: Wed Jul 30 16:49:08 2025 +0800 Merge remote-tracking branch 'gh/main' into feat/rltl-rstest commit bfdebd0 Author: Yiming Li <yimingli.cs@gmail.com> Date: Wed Jul 30 16:48:09 2025 +0800 feat: remove layer from testing rules commit 4591409 Author: Yiming Li <yimingli.cs@gmail.com> Date: Wed Jul 30 15:35:44 2025 +0800 Update .changeset/red-lamps-arrive.md Co-authored-by: Zhiyuan Hong <28915578+hzy@users.noreply.github.com> Signed-off-by: Yiming Li <yimingli.cs@gmail.com> commit fc20380 Merge: b9c1ca2 343cedb Author: Yiming Li <yimingli.cs@gmail.com> Date: Fri Jul 25 15:29:13 2025 +0800 Merge remote-tracking branch 'gh/main' into feat/rltl-rstest commit b9c1ca2 Author: Yiming Li <yimingli.cs@gmail.com> Date: Fri Jul 25 15:18:16 2025 +0800 fix: cr commit 2300227 Author: Yiming Li <yimingli.cs@gmail.com> Date: Thu Jul 24 20:20:50 2025 +0800 docs: update changeset commit 6d0d454 Merge: fe86acd 3788b61 Author: Yiming Li <yimingli.cs@gmail.com> Date: Thu Jul 24 19:29:31 2025 +0800 Merge branch 'main' into feat/rltl-rstest commit fe86acd Author: Yiming Li <yimingli.cs@gmail.com> Date: Thu Jul 24 17:30:30 2025 +0800 fix: cr commit a769bc5 Author: Yiming Li <yimingli.cs@gmail.com> Date: Thu Jul 24 17:29:10 2025 +0800 chore: pnpm dedupe commit 1163c32 Author: Yiming Li <yimingli.cs@gmail.com> Date: Thu Jul 24 17:24:09 2025 +0800 feat: using callerName and reuse lynx.config for rstest commit b391cb8 Author: Yiming Li <yimingli.cs@gmail.com> Date: Thu Jul 24 16:07:41 2025 +0800 feat: keep the `createVitestConfig` API commit 000961d Author: Yiming Li <yimingli.cs@gmail.com> Date: Thu Jul 24 14:58:17 2025 +0800 fix: use cjs for polyfill commit df4d0a3 Author: Yiming Li <yimingli.cs@gmail.com> Date: Thu Jul 24 14:51:00 2025 +0800 chore: use catalog for rstest version commit fea9d67 Merge: 04cbe34 a6230e2 Author: Yiming Li <yimingli.cs@gmail.com> Date: Thu Jul 24 14:45:14 2025 +0800 Merge remote-tracking branch 'gh/main' into feat/rltl-rstest commit 04cbe34 Merge: dae4616 16a3ccb Author: Yiming Li <yimingli.cs@gmail.com> Date: Fri Jul 18 23:48:43 2025 +0800 Merge branch 'main' into feat/rltl-rstest commit dae4616 Author: Yiming <yimingli.cs@gmail.com> Date: Fri Jul 18 23:47:07 2025 +0800 chore: update changeset commit 5b45cfb Author: Yiming <yimingli.cs@gmail.com> Date: Fri Jul 18 17:27:52 2025 +0800 feat: update snapshot commit a0a21b6 Author: Yiming Li <yimingli.cs@gmail.com> Date: Fri Jul 18 17:05:11 2025 +0800 fix coderabbitai cr commit 9a44a9a Author: Yiming Li <yimingli.cs@gmail.com> Date: Fri Jul 18 16:51:32 2025 +0800 feat: add rstest template commit c51a15a Author: Yiming <yimingli.cs@gmail.com> Date: Fri Jul 18 16:43:18 2025 +0800 chore: add testTimeout for rstest commit d3dce4a Author: Yiming <yimingli.cs@gmail.com> Date: Fri Jul 18 16:39:50 2025 +0800 fix: rstest setup commit d8a0221 Merge: dc74726 7eb5c36 Author: Yiming <yimingli.cs@gmail.com> Date: Fri Jul 18 15:05:25 2025 +0800 Merge branch 'feat/rltl-rstest' of github.com:upupming/lynx-stack into feat/rltl-rstest commit dc74726 Author: Yiming <yimingli.cs@gmail.com> Date: Fri Jul 18 15:05:07 2025 +0800 fix: setup file order in vitest commit fe0fd93 Author: Yiming <yimingli.cs@gmail.com> Date: Fri Jul 18 14:19:42 2025 +0800 feat: pre-bundled @lynx-js/testing-environment should shared between vitest and rstest commit 7eb5c36 Author: Yiming Li <yimingli.cs@gmail.com> Date: Fri Jul 18 14:02:03 2025 +0800 fix: enableTestingLibrary passing to ReactWebpackPlugin commit f4a9651 Author: Yiming Li <yimingli.cs@gmail.com> Date: Fri Jul 18 13:54:19 2025 +0800 feat: add template to create-rspeedy commit 410e1c9 Author: Yiming Li <yimingli.cs@gmail.com> Date: Fri Jul 18 11:34:59 2025 +0800 fix: use `enableTestingLibrary` instead of process.env.NODE_ENV to avoid breaking current tests commit a0f2275 Author: Yiming Li <yimingli.cs@gmail.com> Date: Thu Jul 17 22:17:00 2025 +0800 fix: api commit 2442e36 Author: Yiming Li <yimingli.cs@gmail.com> Date: Thu Jul 17 22:08:32 2025 +0800 fix: unused Console type commit 854e2f1 Author: Yiming Li <yimingli.cs@gmail.com> Date: Thu Jul 17 21:46:15 2025 +0800 fix: global.console in rstest cannot be modify commit 852025f Merge: af8a651 6af75c1 Author: Yiming Li <yimingli.cs@gmail.com> Date: Thu Jul 17 21:45:02 2025 +0800 Merge remote-tracking branch 'gh/main' into feat/rltl-rstest commit af8a651 Author: Yiming Li <yimingli.cs@gmail.com> Date: Thu Jul 17 21:05:01 2025 +0800 feat: support rstest in testing library
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds rstest support across the repo: new rstest configs/adapters, test loaders, environment refactor (LynxTestingEnv now accepts a {window} env), create-rspeedy rstest templates, many test snapshot updates, and CI to run rstest alongside Vitest. Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Actionable comments posted: 11
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (4)
packages/rspeedy/create-rspeedy/src/index.ts (1)
113-127:⚠️ Potential issue | 🟠 Major
mapESLintTemplate()always picks the TS template forreact-*.Line 114 matches on
templateName.startsWith(template), but bothTemplateentries usetemplate: 'react', sofind()always returns the first item (lang: 'ts'). That makesreact-js,react-vitest-rltl-js, andreact-rstest-rltl-jsresolve toreact-ts, which will scaffold the wrong ESLint template for JS projects.Proposed fix
mapESLintTemplate(templateName) { - const lang = TEMPLATES.find(({ template }) => - templateName.startsWith(template) - )?.lang + const match = templateName.match(/-(js|ts)$/) + const lang = match?.[1] as LANG | undefined if (!lang) return null🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/rspeedy/create-rspeedy/src/index.ts` around lines 113 - 127, mapESLintTemplate incorrectly uses TEMPLATES.find(({ template }) => templateName.startsWith(template)) which always returns the first 'react' entry (ts); update mapESLintTemplate to match the full template identifier rather than a prefix. Specifically, change the find predicate to compare equality (templateName === template) or otherwise select the most specific template (e.g., sort TEMPLATES by template.length desc before find) so entries like 'react-js' resolve to the 'js' lang; keep references to the existing mapESLintTemplate function and the TEMPLATES array when making the change.packages/react/testing-library/src/__tests__/lazy-bundle/index.test.jsx (1)
309-356:⚠️ Potential issue | 🟡 MinorNormalize the
__RSTEST__predicate.Lines 25 and 58 treat a falsy
__RSTEST__as “not rstest”, but Lines 309 and 355 only special-caseundefined. If the flag is ever injected asfalse, this test will take the non-rstest branch above and silently skip the teardown assertions here.♻️ Suggested cleanup
const require = createRequire(import.meta.url); +const isRstest = typeof __RSTEST__ !== 'undefined' && __RSTEST__; function LazyComponentLoader({ url }) { const ExternalComponent = lazy(() => import(url)); const InternalComponent = lazy(() => import('./LazyComponent')); @@ - {(typeof __RSTEST__ !== 'undefined' && __RSTEST__) ? null : <ExternalComponent />} + {isRstest ? null : <ExternalComponent />} @@ - if (typeof __RSTEST__ !== 'undefined' && __RSTEST__) { + if (isRstest) { @@ - if (typeof __RSTEST__ === 'undefined') { + if (!isRstest) { @@ - if (typeof __RSTEST__ === 'undefined') { + if (!isRstest) {🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/react/testing-library/src/__tests__/lazy-bundle/index.test.jsx` around lines 309 - 356, The test currently checks typeof __RSTEST__ === 'undefined' in some branches but uses a different falsy check elsewhere; make the predicate consistent by treating any falsy __RSTEST__ as "not rstest" (e.g., replace typeof __RSTEST__ === 'undefined' with if (!__RSTEST__) in the test file) so both the branch guarding the tearDownInstances assertions and the other branches use the same check; update occurrences referencing __RSTEST__ (and keep assertions on tearDownInstances unchanged) to use the unified !__RSTEST__ predicate.packages/react/testing-library/src/plugins/vitest.ts (2)
74-93:⚠️ Potential issue | 🟠 MajorHonor
runtimePkgNamein the React aliases.When
runtimePkgName !== '@lynx-js/react', the transform already rewrites generated imports to the custom runtime, butreact,react/jsx-runtime, andreact/jsx-dev-runtimeare still hard-coded to@lynx-js/react. That mixes two runtimes in one test build and makesruntimePkgNameincomplete for projects importing fromreact.♻️ Suggested fix
const reactAlias = [ { find: /^react$/, - replacement: require.resolve(runtimeOSSPkgName, { + replacement: require.resolve(runtimePkgName, { paths: [runtimeDir, __dirname], }), }, { find: /^react\/jsx-runtime$/, - replacement: require.resolve(path.posix.join(runtimeOSSPkgName, 'jsx-runtime'), { + replacement: require.resolve(path.posix.join(runtimePkgName, 'jsx-runtime'), { paths: [runtimeDir, __dirname], }), }, { find: /^react\/jsx-dev-runtime$/, - replacement: require.resolve(path.posix.join(runtimeOSSPkgName, 'jsx-dev-runtime'), { + replacement: require.resolve(path.posix.join(runtimePkgName, 'jsx-dev-runtime'), { paths: [runtimeDir, __dirname], }), }, ];🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/react/testing-library/src/plugins/vitest.ts` around lines 74 - 93, The reactAlias array currently resolves replacements using runtimeOSSPkgName, which hard-codes `@lynx-js/react`; update the three alias entries in reactAlias to use runtimePkgName instead of runtimeOSSPkgName (and use path.posix.join(runtimePkgName, 'jsx-runtime') / 'jsx-dev-runtime' for those two) so that imports for 'react', 'react/jsx-runtime', and 'react/jsx-dev-runtime' are redirected to the configured runtimePkgName (keep existing require.resolve calls and paths array with runtimeDir and __dirname).
141-168:⚠️ Potential issue | 🟠 MajorMove dependency resolution to
configResolvedhook and return a partial config instead of mutating input.The
config()hook receives raw, unresolved configuration. Vitest'stest.aliascan be either an object or an array; calling.push()on line 164 assumes it's an array and will fail if it's configured as an object. Additionally,config.rootmay not be set whenconfig()runs. Useconfig()to return a partialtestconfig with the alias, and move the dependency resolution (lines 142, 166–168) to theconfigResolved()hook for accessing the finalized config. ThetransformReactLynxPluginin this file demonstrates the correct pattern (lines 293–308).🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/react/testing-library/src/plugins/vitest.ts` around lines 141 - 168, The config() hook currently mutates the incoming config and assumes test.alias is an array and config.root is set; instead return a partial test config that includes the reactCompilerRuntimeAlias (do not call .push on config.test) and move dependency resolution and require logic to configResolved(). Concretely: in the config() implementation build reactCompilerRuntimeAlias (same regex and replacement logic) but return { test: { alias: reactCompilerRuntimeAlias } } rather than mutating config; then implement configResolved(resolvedConfig) to set rootContext = resolvedConfig.root, call compilerDeps = resolveCompilerDeps(rootContext), extract babelPath and require babel there (using the same babelPath symbol), and avoid touching config.test there. Use the transformReactLynxPlugin pattern for guidance.
🧹 Nitpick comments (6)
packages/testing-library/examples/basic/src/__tests__/index.test.tsx (1)
12-17: Consider adding type safety for therstestglobal.The
rstestglobal isn't recognized by TypeScript. For consistency with the existing@ts-expect-errorpattern on line 6 and strict TypeScript compliance, consider adding a type annotation or suppression comment.♻️ Suggested improvement
-let fn; -if (typeof rstest !== 'undefined') { - fn = rstest.fn; -} else { - fn = vi.fn; -} +// `@ts-expect-error` rstest global is injected by rstest runner +const fn = typeof rstest !== 'undefined' ? rstest.fn : vi.fn;🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/testing-library/examples/basic/src/__tests__/index.test.tsx` around lines 12 - 17, The test references the untyped global rstest when assigning fn (using rstest.fn or vi.fn), causing TypeScript errors; fix by adding a local type declaration or suppression for rstest before its use — for example add a single-line declaration like "declare const rstest: any;" at the top of the test file (or a narrower type such as "declare const rstest: { fn: typeof vi.fn } | undefined;"), or place a targeted "// `@ts-expect-error`" immediately above the rstest access to silence the error while keeping the existing fn assignment logic (affecting the rstest, fn, and vi.fn usage).packages/react/testing-library/src/__tests__/list.test.jsx (1)
483-569: Drop the second identical snapshot assertion.There’s no state change between Line 395 and Line 483, so this block is a verbatim duplicate of the previous
expect(list).toMatchInlineSnapshot(...). Keeping both just doubles snapshot churn when the list shape changes.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/react/testing-library/src/__tests__/list.test.jsx` around lines 483 - 569, Remove the duplicated inline snapshot assertion: there are two identical expect(list).toMatchInlineSnapshot(...) calls; delete the second occurrence (the block starting with expect(list).toMatchInlineSnapshot that reproduces the same snapshot shown) so only the original snapshot assertion remains and snapshot churn is avoided.packages/rspeedy/plugin-react/test/config.test.ts (1)
2520-2531: Move async setup intobeforeAllfor cleaner test structure.The current pattern initializes
rsbuildandconfigat the describe block level using top-levelawait. While this works, usingbeforeAllis more conventional and makes the test setup explicit:describe('callerName: rstest', () => { let config: Awaited<ReturnType<RsbuildInstance['initConfigs']>>[0]; let rules: Rule[] | undefined; beforeAll(async () => { const { pluginReactLynx } = await import('../src/pluginReactLynx.js'); const rsbuild = await createRspeedy({ rspeedyConfig: { plugins: [pluginReactLynx()] }, callerName: 'rstest', }); [config] = await rsbuild.initConfigs(); rules = config?.module?.rules as Rule[] | undefined; }); // tests... });🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/rspeedy/plugin-react/test/config.test.ts` around lines 2520 - 2531, The test currently performs async initialization at the describe-top level; move that setup into a beforeAll to make tests deterministic and cleaner: import pluginReactLynx, create the rsbuild via createRspeedy, call rsbuild.initConfigs() and assign the first item to config inside a beforeAll, then extract rules from config.module.rules into a top-level let-bound variable for the describe block; reference the pluginReactLynx import, createRspeedy call, rsbuild.initConfigs invocation, the config variable and rules extraction when making the change.packages/rspeedy/plugin-react/src/pluginReactLynx.ts (1)
348-361: Consider consolidating the rstest conditional blocks.The rstest-specific logic is split across multiple conditional blocks. While functionally correct, consolidating could improve readability:
if (isRstest) { applyRstest(api) applyTestingLoaders(api, resolvedOptions) } else { applyCSS(api, resolvedOptions) applyLoaders(api, resolvedOptions) }This would make the rstest vs non-rstest code paths more explicit and easier to follow.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/rspeedy/plugin-react/src/pluginReactLynx.ts` around lines 348 - 361, The code splits rstest behavior across multiple conditionals which reduces readability; refactor the block around the isRstest flag in pluginReactLynx.ts to use a single if/else: when isRstest is true call applyRstest(api) and applyTestingLoaders(api, resolvedOptions); otherwise call applyCSS(api, resolvedOptions) and applyLoaders(api, resolvedOptions); keep the other unconditional calls (applyEntry, applyBackgroundOnly, applyGenerator) in place and do not change their order.packages/react/testing-library/src/env/rstest.ts (1)
3-8: Consider adding type declarations for global properties.The
@ts-ignoresuppresses type errors for the custom global properties. While functional, adding type augmentation would improve type safety and IDE support.♻️ Optional: Add type declarations
Create or extend a global type declaration:
declare global { var jsdom: { window: typeof window }; var lynxTestingEnv: import('./index.js').LynxTestingEnv; }Then the
@ts-ignorecan be removed:-// `@ts-ignore` global.jsdom = { window, }; const lynxTestingEnv = new LynxTestingEnv(); global.lynxTestingEnv = lynxTestingEnv;🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/react/testing-library/src/env/rstest.ts` around lines 3 - 8, Add proper TypeScript global augmentations instead of using `@ts-ignore`: declare global with var jsdom: { window: typeof window } and var lynxTestingEnv: import('./index.js').LynxTestingEnv (or point to the LynxTestingEnv type), place this in a .d.ts or at top of the module so the compiler knows the shapes, then remove the // `@ts-ignore` and keep the assignments to global.jsdom and global.lynxTestingEnv as-is; reference the LynxTestingEnv type from index.js to ensure correct typing.packages/react/testing-library/src/setupFiles/inner/rstest.js (1)
18-20: Unusedcallbackparameter inrequireModuleAsyncstub.The
callbackparameter is declared but never used since the function throws immediately. Consider removing it or, if the signature must match the real API for type compatibility, prefix with underscore to indicate intentional non-use.♻️ Suggested fix
- target.lynx.requireModuleAsync = async (url, callback) => { + target.lynx.requireModuleAsync = async (url, _callback) => { throw new Error('lynx.requireModuleAsync not implemented for rstest'); };🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/react/testing-library/src/setupFiles/inner/rstest.js` around lines 18 - 20, The stub function target.lynx.requireModuleAsync declares an unused parameter callback; either remove the parameter from the function signature or, if you must preserve the API shape for compatibility, rename it to _callback (or _callback) to indicate intentional non-use and silence linters — update the function declaration for requireModuleAsync accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.github/workflows/test.yml:
- Around line 210-215: The scaffold command is being run from inside the
previously created create-rspeedy-regression-vitest-rltl directory, causing the
new create-rspeedy-regression-rstest-rltl project to be nested and possibly
inherit parent config; fix by creating and switching to a fresh temporary
directory (e.g., mktemp -d or similar) before running the npx
create-rspeedy-canary@latest ... --dir create-rspeedy-regression-rstest-rltl
sequence, run pnpm install/build/test there, and then optionally cd back to the
original directory so the test runs operate on an isolated fresh app rather than
a child of create-rspeedy-regression-vitest-rltl.
In `@packages/react/testing-library/.npmignore`:
- Around line 2-3: The .npmignore currently attempts to un-ignore contents with
patterns '!dist/**/*' and '!types/*' but leaves the parent directories ignored
by the top-level '*' rule; update the file to explicitly un-ignore the
directories themselves before their contents (e.g., add patterns to un-ignore
'dist' and 'types' such as '!dist/' and '!types/' and keep or add recursive
content patterns like '!dist/**/*' and '!types/**/*') so npm will include the
dist/ and types/ directories and their files when publishing.
In `@packages/react/testing-library/src/__tests__/css/index.test.jsx`:
- Around line 37-38: Update the inline comment above the assertion for
style3.baz to correct the typo "an string" to "a string" so it reads "to be a
string"; the test assertion itself (expect(style3.baz).toBeTypeOf('string'))
remains unchanged—just edit the comment near the expect call referencing
style3.baz.
In `@packages/react/testing-library/src/__tests__/lazy-bundle/index.test.jsx`:
- Line 25: The test was weakened for rstest by short-circuiting the external
lazy import via the conditional around ExternalComponent (the __RSTEST__ check),
changing assertions to accept the smaller tree, and removing delayed tearDown
checks; restore the original behavior by removing the conditional that bypasses
<ExternalComponent /> when __RSTEST__ is defined (so the external lazy(() =>
import(url)) case runs), revert the assertions in the block that was changed
(the assertion updates around the smaller tree) back to the original
expectations, and re-enable the delayed teardown/snapshot cleanup checks that
were removed; if running the external bundle is impossible in rstest, explicitly
mark the affected tests as skipped or TODO (using test.skip or a clear TODO
comment) so the limitation is visible instead of silently weakening the test.
In `@packages/react/testing-library/src/env/vitest.ts`:
- Around line 7-21: The setup currently creates fakeGlobal and calls
builtinEnvironments.jsdom.setup without capturing its return value, constructs
LynxTestingEnv without the jsdom instance, and doesn't expose Node; fix by
capturing the jsdom setup result (e.g., const jsdomTeardown = await
builtinEnvironments.jsdom.setup(fakeGlobal, {})), pass fakeGlobal.jsdom into the
LynxTestingEnv constructor when instantiating LynxTestingEnv, set global.Node =
fakeGlobal.jsdom.window.Node, and in the returned teardown call the captured
jsdomTeardown (if present) before deleting global.lynxTestingEnv and
global.jsdom so the builtin jsdom teardown is chained and cleanup is complete.
In `@packages/react/testing-library/src/setupFiles/common/runtime-setup.js`:
- Around line 156-159: The code temporarily replaces globalThis.lynxCoreInject
with target.lynxCoreInject and calls injectTt(), but if injectTt() throws the
original value isn't restored; wrap the assignment and call in a try...finally
so that oldLynxCoreInject is always restored in the finally block (use the
existing oldLynxCoreInject variable), ensuring globalThis.lynxCoreInject is
reset even on exceptions from injectTt().
In
`@packages/rspeedy/create-rspeedy/template-react-rstest-rltl-js/rstest.config.js`:
- Around line 7-8: The ESM config uses require.resolve() directly which is
undefined; import createRequire from 'module' using
createRequire(import.meta.url) and replace
require.resolve('@lynx-js/react/testing-library/setupFiles/rstest') with
requireInstance.resolve('@lynx-js/react/testing-library/setupFiles/rstest') so
the setupFiles entry resolves correctly in rstest.config.js (locate the
setupFiles array and the require.resolve call to update).
In
`@packages/rspeedy/create-rspeedy/template-react-rstest-rltl-js/src/__tests__/index.test.jsx`:
- Around line 74-79: The test snapshot in src/__tests__/index.test.jsx
incorrectly references "src/App.tsx" (TypeScript) for the JS scaffold; update
the snapshot string to "src/App.jsx" (or regenerate the snapshot) so the Edit
hint and expectations match the JS template, and verify the template files
(App.jsx) and the test's expected markup (the <text> element containing the file
path) are consistent.
In `@packages/rspeedy/create-rspeedy/template-react-rstest-rltl-js/src/App.jsx`:
- Around line 37-45: The scaffold hint currently points to the wrong file name;
update the string inside the nested <text> element (the one rendered under <text
className='Hint'> in App.jsx) from " src/App.tsx " to " src/App.jsx " so the UI
correctly directs users to the generated file (change the literal text content
inside that nested <text> element).
In `@packages/rspeedy/plugin-react/src/loaders.ts`:
- Around line 35-46: getLoaderOptions is not including the engineVersion from
its Required<PluginReactLynxOptions> param in the returned options object,
causing snapshots to miss engineVersion; update the function to destructure
engineVersion from the parameters and add engineVersion to the returned object
alongside compat, enableRemoveCSSScope, isDynamicComponent,
inlineSourcesContent, defineDCE and conditional shake so the returned shape
matches tests (refer to getLoaderOptions and the returned object currently
containing compat, enableRemoveCSSScope, isDynamicComponent,
inlineSourcesContent, defineDCE, and conditional shake).
In `@packages/rspeedy/plugin-react/src/rstest.ts`:
- Around line 7-13: The current api.modifyRsbuildConfig callback overwrites
config.output.externals and loses any existing externals; update the handler in
the modifyRsbuildConfig callback to read config.output?.externals, normalize it
to an array (wrap non-array values), append the /^node:/ regexp, and then call
mergeRsbuildConfig with the original config followed by the new output.externals
array so you preserve prior externals while adding the node: matcher.
---
Outside diff comments:
In `@packages/react/testing-library/src/__tests__/lazy-bundle/index.test.jsx`:
- Around line 309-356: The test currently checks typeof __RSTEST__ ===
'undefined' in some branches but uses a different falsy check elsewhere; make
the predicate consistent by treating any falsy __RSTEST__ as "not rstest" (e.g.,
replace typeof __RSTEST__ === 'undefined' with if (!__RSTEST__) in the test
file) so both the branch guarding the tearDownInstances assertions and the other
branches use the same check; update occurrences referencing __RSTEST__ (and keep
assertions on tearDownInstances unchanged) to use the unified !__RSTEST__
predicate.
In `@packages/react/testing-library/src/plugins/vitest.ts`:
- Around line 74-93: The reactAlias array currently resolves replacements using
runtimeOSSPkgName, which hard-codes `@lynx-js/react`; update the three alias
entries in reactAlias to use runtimePkgName instead of runtimeOSSPkgName (and
use path.posix.join(runtimePkgName, 'jsx-runtime') / 'jsx-dev-runtime' for those
two) so that imports for 'react', 'react/jsx-runtime', and
'react/jsx-dev-runtime' are redirected to the configured runtimePkgName (keep
existing require.resolve calls and paths array with runtimeDir and __dirname).
- Around line 141-168: The config() hook currently mutates the incoming config
and assumes test.alias is an array and config.root is set; instead return a
partial test config that includes the reactCompilerRuntimeAlias (do not call
.push on config.test) and move dependency resolution and require logic to
configResolved(). Concretely: in the config() implementation build
reactCompilerRuntimeAlias (same regex and replacement logic) but return { test:
{ alias: reactCompilerRuntimeAlias } } rather than mutating config; then
implement configResolved(resolvedConfig) to set rootContext =
resolvedConfig.root, call compilerDeps = resolveCompilerDeps(rootContext),
extract babelPath and require babel there (using the same babelPath symbol), and
avoid touching config.test there. Use the transformReactLynxPlugin pattern for
guidance.
In `@packages/rspeedy/create-rspeedy/src/index.ts`:
- Around line 113-127: mapESLintTemplate incorrectly uses TEMPLATES.find(({
template }) => templateName.startsWith(template)) which always returns the first
'react' entry (ts); update mapESLintTemplate to match the full template
identifier rather than a prefix. Specifically, change the find predicate to
compare equality (templateName === template) or otherwise select the most
specific template (e.g., sort TEMPLATES by template.length desc before find) so
entries like 'react-js' resolve to the 'js' lang; keep references to the
existing mapESLintTemplate function and the TEMPLATES array when making the
change.
---
Nitpick comments:
In `@packages/react/testing-library/src/__tests__/list.test.jsx`:
- Around line 483-569: Remove the duplicated inline snapshot assertion: there
are two identical expect(list).toMatchInlineSnapshot(...) calls; delete the
second occurrence (the block starting with expect(list).toMatchInlineSnapshot
that reproduces the same snapshot shown) so only the original snapshot assertion
remains and snapshot churn is avoided.
In `@packages/react/testing-library/src/env/rstest.ts`:
- Around line 3-8: Add proper TypeScript global augmentations instead of using
`@ts-ignore`: declare global with var jsdom: { window: typeof window } and var
lynxTestingEnv: import('./index.js').LynxTestingEnv (or point to the
LynxTestingEnv type), place this in a .d.ts or at top of the module so the
compiler knows the shapes, then remove the // `@ts-ignore` and keep the
assignments to global.jsdom and global.lynxTestingEnv as-is; reference the
LynxTestingEnv type from index.js to ensure correct typing.
In `@packages/react/testing-library/src/setupFiles/inner/rstest.js`:
- Around line 18-20: The stub function target.lynx.requireModuleAsync declares
an unused parameter callback; either remove the parameter from the function
signature or, if you must preserve the API shape for compatibility, rename it to
_callback (or _callback) to indicate intentional non-use and silence linters —
update the function declaration for requireModuleAsync accordingly.
In `@packages/rspeedy/plugin-react/src/pluginReactLynx.ts`:
- Around line 348-361: The code splits rstest behavior across multiple
conditionals which reduces readability; refactor the block around the isRstest
flag in pluginReactLynx.ts to use a single if/else: when isRstest is true call
applyRstest(api) and applyTestingLoaders(api, resolvedOptions); otherwise call
applyCSS(api, resolvedOptions) and applyLoaders(api, resolvedOptions); keep the
other unconditional calls (applyEntry, applyBackgroundOnly, applyGenerator) in
place and do not change their order.
In `@packages/rspeedy/plugin-react/test/config.test.ts`:
- Around line 2520-2531: The test currently performs async initialization at the
describe-top level; move that setup into a beforeAll to make tests deterministic
and cleaner: import pluginReactLynx, create the rsbuild via createRspeedy, call
rsbuild.initConfigs() and assign the first item to config inside a beforeAll,
then extract rules from config.module.rules into a top-level let-bound variable
for the describe block; reference the pluginReactLynx import, createRspeedy
call, rsbuild.initConfigs invocation, the config variable and rules extraction
when making the change.
In `@packages/testing-library/examples/basic/src/__tests__/index.test.tsx`:
- Around line 12-17: The test references the untyped global rstest when
assigning fn (using rstest.fn or vi.fn), causing TypeScript errors; fix by
adding a local type declaration or suppression for rstest before its use — for
example add a single-line declaration like "declare const rstest: any;" at the
top of the test file (or a narrower type such as "declare const rstest: { fn:
typeof vi.fn } | undefined;"), or place a targeted "// `@ts-expect-error`"
immediately above the rstest access to silence the error while keeping the
existing fn assignment logic (affecting the rstest, fn, and vi.fn usage).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: eba85ea0-3457-42c3-98d7-badfef5d8d30
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (72)
.changeset/easy-waves-pump.md.changeset/ninety-pants-tease.md.changeset/red-lamps-arrive.md.github/workflows/test.ymlpackage.jsonpackages/react/package.jsonpackages/react/testing-library/.npmignorepackages/react/testing-library/package.jsonpackages/react/testing-library/rslib.config.tspackages/react/testing-library/rstest.config.tspackages/react/testing-library/src/__tests__/act.test.jsxpackages/react/testing-library/src/__tests__/alog.test.jsxpackages/react/testing-library/src/__tests__/auto-cleanup-skip.test.jsxpackages/react/testing-library/src/__tests__/cleanup.test.jsxpackages/react/testing-library/src/__tests__/css/index.test.jsxpackages/react/testing-library/src/__tests__/end-to-end.test.jsxpackages/react/testing-library/src/__tests__/lazy-bundle/index.test.jsxpackages/react/testing-library/src/__tests__/list.test.jsxpackages/react/testing-library/src/__tests__/lynx.test.jsxpackages/react/testing-library/src/__tests__/rerender.test.jsxpackages/react/testing-library/src/__tests__/worklet.test.jsxpackages/react/testing-library/src/env/index.tspackages/react/testing-library/src/env/rstest.tspackages/react/testing-library/src/env/vitest.tspackages/react/testing-library/src/plugins/index.tspackages/react/testing-library/src/plugins/vitest.tspackages/react/testing-library/src/setupFiles/common/bootstrap.jspackages/react/testing-library/src/setupFiles/common/runtime-setup.jspackages/react/testing-library/src/setupFiles/inner/rstest.jspackages/react/testing-library/src/setupFiles/inner/vitest.jspackages/react/testing-library/src/setupFiles/rstest.jspackages/react/testing-library/src/setupFiles/vitest.jspackages/react/testing-library/src/vitest.config.tspackages/react/testing-library/types/vitest-config.d.tspackages/react/testing-library/vitest-polyfill.cjspackages/react/testing-library/vitest.config.tspackages/rspeedy/create-rspeedy/package.jsonpackages/rspeedy/create-rspeedy/src/index.tspackages/rspeedy/create-rspeedy/template-react-rstest-rltl-js/lynx.config.jspackages/rspeedy/create-rspeedy/template-react-rstest-rltl-js/package.jsonpackages/rspeedy/create-rspeedy/template-react-rstest-rltl-js/rstest.config.jspackages/rspeedy/create-rspeedy/template-react-rstest-rltl-js/src/App.jsxpackages/rspeedy/create-rspeedy/template-react-rstest-rltl-js/src/__tests__/index.test.jsxpackages/rspeedy/create-rspeedy/template-react-rstest-rltl-js/src/index.jsxpackages/rspeedy/create-rspeedy/template-react-rstest-rltl-ts/lynx.config.tspackages/rspeedy/create-rspeedy/template-react-rstest-rltl-ts/package.jsonpackages/rspeedy/create-rspeedy/template-react-rstest-rltl-ts/rstest.config.tspackages/rspeedy/create-rspeedy/template-react-rstest-rltl-ts/src/App.tsxpackages/rspeedy/create-rspeedy/template-react-rstest-rltl-ts/src/__tests__/index.test.tsxpackages/rspeedy/create-rspeedy/template-react-rstest-rltl-ts/src/index.tsxpackages/rspeedy/create-rspeedy/template-react-rstest-rltl-ts/src/rspeedy-env.d.tspackages/rspeedy/create-rspeedy/template-react-rstest-rltl-ts/tsconfig.jsonpackages/rspeedy/create-rspeedy/template-react-vitest-rltl-js/vitest.config.jspackages/rspeedy/create-rspeedy/template-react-vitest-rltl-ts/vitest.config.tspackages/rspeedy/plugin-react/package.jsonpackages/rspeedy/plugin-react/src/loaders.tspackages/rspeedy/plugin-react/src/pluginReactLynx.tspackages/rspeedy/plugin-react/src/rspeedy-api.tspackages/rspeedy/plugin-react/src/rstest.tspackages/rspeedy/plugin-react/test/config.test.tspackages/testing-library/examples/basic/package.jsonpackages/testing-library/examples/basic/rstest.config.tspackages/testing-library/examples/basic/src/__tests__/index.test.tsxpackages/testing-library/examples/basic/src/rspeedy-env.d.tspackages/testing-library/examples/basic/vitest.config.tspackages/testing-library/testing-environment/src/index.tspackages/use-sync-external-store/vitest.config.tspackages/webpack/react-webpack-plugin/etc/react-webpack-plugin.api.mdpackages/webpack/react-webpack-plugin/src/ReactWebpackPlugin.tspackages/webpack/react-webpack-plugin/src/loaders/options.tspackages/webpack/react-webpack-plugin/src/loaders/testing.tspnpm-workspace.yaml
💤 Files with no reviewable changes (1)
- packages/react/testing-library/types/vitest-config.d.ts
Web Explorer#8803 Bundle Size — 748.66KiB (0%).527ed7c(current) vs fd0cc6e main#8801(baseline) Bundle metrics
Bundle size by type
|
| Current #8803 |
Baseline #8801 |
|
|---|---|---|
401.63KiB |
401.63KiB |
|
344.87KiB |
344.87KiB |
|
2.16KiB |
2.16KiB |
Bundle analysis report Branch feat/rstest-rltl Project dashboard
Generated by RelativeCI Documentation Report issue
Merging this PR will degrade performance by 26.68%
Performance Changes
Comparing Footnotes
|
🦋 Changeset detectedLatest commit: 527ed7c The changes in this PR will be included in the next version bump. This PR includes changesets to release 9 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
8768da8 to
2f22d7d
Compare
<!-- Thank you for submitting a pull request! We appreciate the time and effort you have invested in making these changes. Please ensure that you provide enough information to allow others to review your pull request. Upon submission, your pull request will be automatically assigned with reviewers. If you want to learn more about contributing to this project, please visit: https://github.com/lynx-family/lynx-stack/blob/main/CONTRIBUTING.md. --> <!-- The AI summary below will be auto-generated - feel free to replace it with your own. --> @coderabbitai summary `@lynx-js/react/testing-library/rstest-adapter` will automatically load your `lynx.config.ts` and apply the same configuration to rstest, so you can keep your test environment consistent with your development environment. ```ts // rstest.config.ts import { defineConfig } from '@rstest/core'; import { withLynxConfig } from '@lynx-js/react/testing-library/rstest-adapter'; export default defineConfig({ extends: withLynxConfig(), }); ``` ## Checklist <!--- Check and mark with an "x" --> - [ ] Tests updated (or not required). - [ ] Documentation updated (or not required). - [ ] Changeset added, and when a BREAKING CHANGE occurs, it needs to be clearly marked (or not required).
<!-- Thank you for submitting a pull request! We appreciate the time and effort you have invested in making these changes. Please ensure that you provide enough information to allow others to review your pull request. Upon submission, your pull request will be automatically assigned with reviewers. If you want to learn more about contributing to this project, please visit: https://github.com/lynx-family/lynx-stack/blob/main/CONTRIBUTING.md. --> <!-- The AI summary below will be auto-generated - feel free to replace it with your own. --> @coderabbitai summary fix rstest lock version. https://github.com/lynx-family/lynx-stack/actions/runs/23236933928/job/67543097691?pr=2328 ## Checklist <!--- Check and mark with an "x" --> - [ ] Tests updated (or not required). - [ ] Documentation updated (or not required). - [ ] Changeset added, and when a BREAKING CHANGE occurs, it needs to be clearly marked (or not required).
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Signed-off-by: Yiming Li <yimingli.cs@gmail.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c493518d47
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Signed-off-by: Yiming Li <yimingli.cs@gmail.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Signed-off-by: Yiming Li <yimingli.cs@gmail.com>
…etup.js Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Signed-off-by: Yiming Li <yimingli.cs@gmail.com>
848a4bd to
1c8cf5f
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b5e918019a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b30dd8817a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
# Conflicts: # packages/react/testing-library/src/__tests__/alog.test.jsx # packages/react/testing-library/src/__tests__/list.test.jsx # packages/react/testing-library/src/setupFiles/common/runtime-setup.js # pnpm-lock.yaml
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6521e71ad1
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6521e71ad1
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5722509c55
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
1 similar comment
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
ab74a92 to
530cdb6
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 530cdb6d03
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
530cdb6 to
99592d3
Compare
<!-- Thank you for submitting a pull request! We appreciate the time and effort you have invested in making these changes. Please ensure that you provide enough information to allow others to review your pull request. Upon submission, your pull request will be automatically assigned with reviewers. If you want to learn more about contributing to this project, please visit: https://github.com/lynx-family/lynx-stack/blob/main/CONTRIBUTING.md. --> <!-- The AI summary below will be auto-generated - feel free to replace it with your own. --> Small Fix for #2328 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Chores** * Updated build task configuration to include an additional upstream dependency, optimizing the build pipeline execution order. <!-- end of auto-generated comment: release notes by coderabbit.ai --> ## Checklist <!--- Check and mark with an "x" --> - [ ] Tests updated (or not required). - [ ] Documentation updated (or not required). - [ ] Changeset added, and when a BREAKING CHANGE occurs, it needs to be clearly marked (or not required).
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## @lynx-js/react@0.119.0 ### Minor Changes - Simplify hooks for main-thread runtime, which only can run during the first screen. ([#2441](#2441)) ### Patch Changes - Remove stale gestures when gestures are removed ([#2297](#2297)) - Trace refactor ([#2466](#2466)) - Remove `ReactLynx::renderOpcodes` from the trace - Use `ReactLynx::transferRoot` to measure the time spent transferring the root to the background thread - refactor: set state of suspense to render fallback ([#2450](#2450)) - Support rstest for testing library, you can use rstest with RLTL now: ([#2328](#2328)) Create a config file `rstest.config.ts` with the following content: ```ts import { defineConfig } from "@rstest/core"; import { withLynxConfig } from "@lynx-js/react/testing-library/rstest-config"; export default defineConfig({ extends: withLynxConfig(), }); ``` `@lynx-js/react/testing-library/rstest-config` will automatically load your `lynx.config.ts` and apply the same configuration to rstest, so you can keep your test environment consistent with your development environment. And then use rstest as usual: ```bash $ rstest ``` For more usage detail, see <https://rstest.rs/> - Update preact version ([#2456](#2456)) - Add `nodeIndex` to generated FiberElement creation calls and expose React transform debug metadata as `uiSourceMapRecords`. ([#2402](#2402)) ## @lynx-js/react-rsbuild-plugin@0.16.0 ### Minor Changes - Simplify hooks for main-thread runtime, which only can run during the first screen. ([#2441](#2441)) ### Patch Changes - Support rstest for testing library using a dedicated testing loader. ([#2328](#2328)) - Fix `environments.lynx.performance.profile` so it overrides the default profile behavior for the current environment. ([#2468](#2468)) - Add `enableUiSourceMap` option to enable UI source map generation and debug-metadata asset emission. ([#2402](#2402)) - Updated dependencies \[[`a9f8d05`](a9f8d05), [`b1ad1b9`](b1ad1b9), [`f6184f3`](f6184f3), [`f6184f3`](f6184f3), [`a9f8d05`](a9f8d05), [`f542d9c`](f542d9c)]: - @lynx-js/template-webpack-plugin@0.10.9 - @lynx-js/react-webpack-plugin@0.9.1 - @lynx-js/react-alias-rsbuild-plugin@0.16.0 - @lynx-js/css-extract-webpack-plugin@0.7.0 - @lynx-js/react-refresh-webpack-plugin@0.3.5 - @lynx-js/use-sync-external-store@1.5.0 ## @lynx-js/react-alias-rsbuild-plugin@0.16.0 ### Minor Changes - Simplify hooks for main-thread runtime, which only can run during the first screen. ([#2441](#2441)) ### Patch Changes - fix(rstest): add global fallback aliases for `@lynx-js/react/jsx-runtime` and `@lynx-js/react/jsx-dev-runtime` ([#2464](#2464)) `pluginReactAlias` only aliased these entries inside layer-specific rules (`issuerLayer: BACKGROUND/MAIN_THREAD`). In rstest mode there are no layers, so JSX transformed by the testing loader—which emits `import { jsx } from '@lynx-js/react/jsx-runtime'`—could not be resolved, causing a `Cannot find module '@lynx-js/react/jsx-runtime'` error. Added global (non-layer-specific) fallback aliases pointing to the background jsx-runtime. ## @lynx-js/testing-environment@0.2.0 ### Minor Changes - **BREAKING CHANGE**: ([#2328](#2328)) Align the public test-environment API around `LynxEnv`. `LynxTestingEnv` now expects a `{ window }`-shaped environment instead of relying on a concrete `JSDOM` instance or `global.jsdom`. Callers that construct `LynxTestingEnv` manually or initialize the environment through globals should migrate to `new LynxTestingEnv({ window })` or set `global.lynxEnv`. This release also adds the `@lynx-js/testing-environment/env/rstest` entry for running the shared testing-environment suite under rstest. ### Patch Changes - Add `__RemoveGestureDetector` PAPI binding ([#2297](#2297)) ## @lynx-js/rspeedy@0.14.2 ### Patch Changes - Updated dependencies \[]: - @lynx-js/web-rsbuild-server-middleware@0.20.2 ## create-rspeedy@0.14.2 ### Patch Changes - Add Rstest ReactLynx Testing Library template. ([#2328](#2328)) ## @lynx-js/external-bundle-rsbuild-plugin@0.1.1 ### Patch Changes - Updated dependencies \[[`3262ca8`](3262ca8)]: - @lynx-js/externals-loading-webpack-plugin@0.1.1 ## @lynx-js/web-core@0.20.2 ### Patch Changes - fix: map clientX and clientY to x and y in touch event detail ([#2458](#2458)) - fix(web-platform): completely detach event listeners and forcefully free `MainThreadWasmContext` pointer alongside strict FIFO async component disposal to ensure total memory reclamation without use-after-free risks ([#2457](#2457)) - refactor: with WeakRef in element APIs and WASM bindings to improve memory management. ([#2439](#2439)) - fix: preserve CSS variable fallback values when encoding web-core stylesheets so declarations like `var(--token, rgba(...))` are emitted with their fallback intact. ([#2460](#2460)) - fix: avoid to do use-after-free for rust instance ([#2461](#2461)) - fix: Change uniqueId to uid in LynxCrossThreadEventTarget ([#2467](#2467)) - Updated dependencies \[]: - @lynx-js/web-worker-rpc@0.20.2 ## @lynx-js/externals-loading-webpack-plugin@0.1.1 ### Patch Changes - fix: deduplicate `loadScript` calls for externals sharing the same (bundle, section) pair ([#2465](#2465)) When multiple externals had different `libraryName` values but pointed to the same bundle URL and section path, `createLoadExternalSync`/`createLoadExternalAsync` was called once per external, causing `lynx.loadScript` to execute redundantly for the same section. Now only the first external in each `(url, sectionPath)` group triggers the load; subsequent externals in the group are assigned the already-loaded result directly. ## @lynx-js/react-webpack-plugin@0.9.1 ### Patch Changes - Support rstest for testing library using a dedicated testing loader. ([#2328](#2328)) - fix(rstest): normalize partial `compat` options in the testing loader ([#2464](#2464)) The testing loader forwards `compat` directly to `transformReactLynxSync` without normalization. When `compat` is supplied as a partial object, the required `target` field is absent and the WASM transform throws `Error: Missing field 'target'`. Added the same normalization already present in `getCommonOptions` for the background/main-thread loaders: fills in `target: 'MIXED'` and all other required fields with sensible defaults. - Add `enableUiSourceMap` option to enable UI source map generation and debug-metadata asset emission. ([#2402](#2402)) ## @lynx-js/template-webpack-plugin@0.10.9 ### Patch Changes - Introduce `LynxDebugMetadataPlugin` to emit debug-metadata assets. ([#2402](#2402)) - Updated dependencies \[[`24c4c69`](24c4c69), [`7332eb4`](7332eb4), [`fd0cc6e`](fd0cc6e), [`e5b0f66`](e5b0f66), [`5aa97d8`](5aa97d8), [`5c39654`](5c39654)]: - @lynx-js/web-core@0.20.2 ## @lynx-js/react-umd@0.119.0 ## upgrade-rspeedy@0.14.2 ## @lynx-js/web-rsbuild-server-middleware@0.20.2 ## @lynx-js/web-worker-rpc@0.20.2 Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Summary
close #1300
This PR introduces rstest support for ReactLynx Testing Library and aligns the public testing APIs around plugin/config composition.
What changed
@lynx-js/react/testing-library/rstest-configwithLynxConfig(...)for app scenarios (reuselynx.config.ts)withDefaultConfig(...)for library scenarios (runner defaults only)rstest-adapternaming withrstest-confignaming for public exports.vitestTestingLibraryPlugin()is now the recommended API.createVitestConfigis deprecated but still supported for backward compatibility.packages/testing-library/examples/basicpackages/testing-library/examples/librarypackages/testing-library/examples/react-compilerRecommended usage
Vitest
Rstest (app)
Rstest (library)
Notes
Checklist