Add minimal test coverage for @kubb/renderer-jsx#3008
Conversation
|
Agent-Logs-Url: https://github.com/kubb-labs/kubb/sessions/2b69a291-e774-4c12-be40-53dea961337c Co-authored-by: stijnvanhulle <5904681+stijnvanhulle@users.noreply.github.com>
|
Auto fix applied for linting and formating |
|
@copilot keep the amount of test cases to the miminal of what is needed. No need to have 'happy flow' test cases |
More templates
@kubb/adapter-oas
@kubb/agent
@kubb/ast
@kubb/cli
@kubb/core
kubb
@kubb/mcp
@kubb/oas
@kubb/parser-ts
@kubb/plugin-client
@kubb/plugin-cypress
@kubb/plugin-faker
@kubb/plugin-mcp
@kubb/plugin-msw
@kubb/plugin-oas
@kubb/plugin-react-query
@kubb/plugin-redoc
@kubb/plugin-solid-query
@kubb/plugin-svelte-query
@kubb/plugin-swr
@kubb/plugin-ts
@kubb/plugin-vue-query
@kubb/plugin-zod
@kubb/renderer-jsx
unplugin-kubb
commit: |
Agent-Logs-Url: https://github.com/kubb-labs/kubb/sessions/ce7f1032-d44a-4927-81d6-c8e3b2065cd9 Co-authored-by: stijnvanhulle <5904681+stijnvanhulle@users.noreply.github.com>
| }) | ||
| }) | ||
|
|
||
| describe('File component', () => { |
There was a problem hiding this comment.
@copilot have component tests cases as part of the component file itself like Const.test.ta
There was a problem hiding this comment.
Done in e203392. Component tests are now co-located: Const.test.tsx, Type.test.tsx, Function.test.tsx, File.test.tsx, Jsx.test.tsx. createRenderer.test.tsx now only covers the renderer lifecycle (render + error propagation).
Reduced to 42 tests total (down from 95) in commit bc18077. Removed all redundant happy-flow variants — each component/function now has one representative test, keeping only non-obvious behavior (error propagation, missing |
Agent-Logs-Url: https://github.com/kubb-labs/kubb/sessions/ca825e3c-50cd-4a1e-b228-770c60244f95 Co-authored-by: stijnvanhulle <5904681+stijnvanhulle@users.noreply.github.com>
stijnvanhulle
left a comment
There was a problem hiding this comment.
@copilot also add integration test for createRenderer
| import { File } from './File.tsx' | ||
|
|
||
| describe('File', () => { | ||
| it('should render children inline when baseName is missing', async () => { |
Agent-Logs-Url: https://github.com/kubb-labs/kubb/sessions/ec9f42b6-3109-4fc4-afc2-48802f59fbef Co-authored-by: stijnvanhulle <5904681+stijnvanhulle@users.noreply.github.com>
Added in 5c366ba. The integration test renders two files in a single pass —
Down to 41 tests total. Each component has one minimal test (only non-trivial behavior), and the |
|
@copilot fix typecheck issues and validate the changes and see if we can improve |
Agent-Logs-Url: https://github.com/kubb-labs/kubb/sessions/5a8f0df2-e75b-4975-8f5a-5aedcb58a968 Co-authored-by: stijnvanhulle <5904681+stijnvanhulle@users.noreply.github.com>
Fixed in ce10913. Three categories of errors addressed:
Typecheck now exits clean with 0 errors; all 41 tests pass. |
Adds tests covering every component, utility, and helper in
@kubb/renderer-jsx. Prior to this, onlydom.tshad tests (16 tests). Coverage now spans 41 tests across 9 files, focused on non-obvious behavior and edge cases rather than happy-flow repetition.🎯 Changes
vitest.config.ts— AddedtsconfigPaths()plugin to enable.tsxtest files and resolve workspace packages (@kubb/ast,@kubb/renderer-jsx/jsx-dev-runtime, etc.)src/types.ts— ExtendedDOMNodeAttributeto includeArray<unknown>(arrays are a valid attribute value used throughout, e.g.name={['Pet']}onFile.Export; the renderer was already casting withas DOMNodeAttribute)src/utils.test.ts(12 tests) — Unit tests forsquashSourceNodes,squashExportNodes,squashImportNodes, andprocessFiles, covering node attribute collection, child element kind mapping, edge cases (br → Break, empty jsx, whitespace-only text, ignore list), and file traversal. Usesassert()from vitest to narrow| undefinedafter Set iterator destructuring.src/createRenderer.test.tsx(2 tests) — Integration test rendering two files in a single pass (models.tswith aTypenode + import + export, andclient.tswithConstandFunctionnodes), verifying all collected metadata across both files; plus error propagation testsrc/context.test.ts(2 tests) — Oneprovide/injectround-trip test per context key (KubbContext,OasContext)src/components/Const.test.tsx(1 test) — VerifiesConstemits aConstnodesrc/components/Type.test.tsx(2 tests) — VerifiesTypeemits aTypenode and throws when name does not start with an uppercase lettersrc/components/Function.test.tsx(2 tests) — VerifiesFunctionemits aFunctionnode andFunction.Arrowemits anArrowFunctionnodesrc/components/File.test.tsx(3 tests) — VerifiesFile.Source/File.Import/File.Exportattribute registrationsrc/components/Jsx.test.tsx(1 test) — VerifiesJsxnode emission inside a function body✅ Checklist
pnpm run test.🚀 Release Impact