test: scaffold Vitest and add initial test suite (100% coverage)#5
Draft
JoseFredes wants to merge 1 commit into
Draft
test: scaffold Vitest and add initial test suite (100% coverage)#5JoseFredes wants to merge 1 commit into
JoseFredes wants to merge 1 commit into
Conversation
- Add Vitest + jsdom + @testing-library/react + @vue/test-utils as devDeps - Wire `npm test`, `test:watch`, `test:coverage` scripts - Add tests for core renderer (validation, props, style, events, attributes, XSS-safe text children) - Add adapter tests (generic, React, Vue 3) covering rendering, event wiring, and HTML-escape behavior - 40 tests, 100% line/branch/function coverage on src/ - Fix `.gitIgnore` casing so node_modules and dist are actually ignored on Linux; add coverage/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The repo had no tests and
npm testwas a placeholder. This PR sets up a test runner and adds an initial suite that brings line/branch/function coverage onsrc/to 100%.@testing-library/react+@vue/test-utils+@vitest/coverage-v8. New scripts:npm test,npm run test:watch,npm run test:coverage.core.ts(test/core.test.ts, 27 tests): input validation (null/undefined/primitives, missingtype, theVALID_HTML_TAGregex against attribute-injection attempts like"div onclick=..."and"<script>"),className/stylehandling, attribute coercion (numeric/boolean/null), event handler wiring + name normalization, and XSS-safe text children..gitignorefix: the existing.gitIgnore(capitalI) was not matched on Linux, sonode_modules/was effectively unignored andnode_modules/.package-lock.jsonwas tracked. Renamed to.gitignore, addedcoverage/, untracked the stray file.Coverage
Follow-ups (not in this PR)
npm teston PRs and gate on coverage.renderComponentFromJSONwithfast-check..d.tsdrift check (tsd/expect-type) —types/jbricks.d.tstypesrenderVueComponentasobject, while the source returns adefineComponentresult.core.tsassigns style keys via bracket assignment, which silently no-ops for kebab-case keys (e.g."background-color"); worth deciding whether to support that and adding a regression test.Test plan
npm testpasses (40/40)npm run test:coveragereports 100%Generated by Claude Code