agentleFS
rjsf-teamrjsf-team/react-jsonschema-form/.claude/skills/rjsf-testing/SKILL.md

rjsf-testing

Skill16k starsChanged 20 days agoApache-2.0View on GitHub

Use when writing, modifying, converting, or debugging any test in this repo, including a regression test added during a bug fix — test helpers, user-event vs fireEvent rules, fake timers, and snapshot updates.

Trending

More talk lately.about the whole repository

Dec 2025: 0 mentionsJan 2026: 0 mentionsFeb 2026: 0 mentionsMar 2026: 0 mentionsApr 2026: 1 mentionMay 2026: 0 mentionsJun 2026: 2 mentionsJul 2026: 3 mentionsAug 2026: 10 mentionsSep 2026: 9 mentionsOct 2026: 6 mentionsNov 2026: 1 mention
Dec 2025Jun 2026Nov 2026
Mentions a month of the rjsf-team/react-jsonschema-form repository that our weekly crawl found. There is no adoption data for this file yet.

Who's talking about rjsf-team/react-jsonschema-form

The biggest 5 of 64 mentions linking to the repository that our crawl found. Each line is their own headline.

See all 64

Talked about on GitHub, Stack Overflow, Hacker News and Bluesky (64 times).

On GitHub · 50

45 more on GitHub

On Stack Overflow · 12

7 more on Stack Overflow

On Hacker News · 1

On Bluesky · 1

  • In this repositoryOne other file it gives its agents.

The file

We split this skill into the rules it gives an agent

1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Run one package's tests with cd packages/<pkg> && pnpm test, or pnpm run test:watch there for watch mode.

    line 9

≈ “Common” is an estimate: at least 1 in 5 of the 364,980 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Testing in react-jsonschema-form

  • Vitest, jsdom and Testing Library; the shared config is testing/vitest.base.ts, extended by each package's own vitest config
  • Run one package's tests with cd packages/<pkg> && pnpm test, or pnpm run test:watch there for watch mode; the root pnpm test runs every package
  • Tests resolve @rjsf/* imports to TypeScript source via the @rjsf/source export condition, so no build is needed before running them
  • Vitest runs with globals: true, testing/testSetup.ts loads @testing-library/jest-dom/vitest, and tsconfig.typecheck.json, which the tests are checked under (chakra-ui's through tsconfig.typecheck-bundler.json, which extends it), lists vitest/globals and @testing-library/jest-dom/vitest in its types, so describe, it, test, expect, expectTypeOf, vi, the before*/after* hooks and the jest-dom matchers are all ambient. Never import a runtime value from 'vitest', in any form; only types, as import type { Mock, MockInstance } from 'vitest'. A no-restricted-imports lint rule on test/, packages/snapshot-tests/src/ and testing/ fails on any other import from 'vitest', aliased, namespace and default forms included
  • Build on the existing test helpers rather than hand-rolling the same setup. packages/core/test/testUtils.tsx holds most of them and is the first place to look before writing scaffolding:
    • createFormComponent(props) renders a Form with the AJV 8 validator wired up and returns { node, onChange, onSubmit, onError, rerender }; createComponent does the same for a themed Form, and createFormRef covers the FormRef cases
    • submitForm(node, user) submits through the real submit button, falling back to fireEvent.submit when there isn't one. Its third argument, forceFireEvent, is the escape hatch for a test where clicking would focus the button and blur a focused field first, or where the browser's own constraint validation would block the submit the test means to make — pass it deliberately and say why
    • fieldErrorsById(node), errorListMessages(node) and expectToHaveBeenCalledWithFormData(mock, formData) for assertions; getSelectedOptionValue(select) for a <select>'s rendered text
    • setupConsoleErrorSuppression() / setupConsoleWarnSuppression() for a test that intentionally triggers a console error, instead of an ad-hoc vi.spyOn(console, ...). They live in testing/consoleSuppression.ts, which testUtils.tsx re-exports, so a theme package's tests import them from there
    • describeRepeated(title, fn) runs a block against both the plain and the omitExtraData form variants
  • A theme package testing a widget or template directly (not through a Form) builds its registry with getTestRegistry() from @rjsf/core/testing, which takes optional rootSchema, fields, templates and widgets. Pass the theme's own Templates when the assertion depends on the theme rendering — the default builds core's registry, so a test that omits them is exercising core's components, not the theme's
  • Drive interactions with @testing-library/user-event, not fireEvent — it dispatches the full event sequence a real interaction produces, so a test can't pass on an event a user could never fire on their own. It's a root devDependency; don't add it to a package:

    import { userEvent } from '@testing-library/user-event';
    
    const user = userEvent.setup(); // module level, after the imports

    One instance per file is the convention here, but it carries pointer and keyboard state across every test in that file. A test that presses without releasing — user.keyboard('{Shift>}'), user.pointer({ keys: '[MouseLeft>]' }) — leaks that held key or button into the tests after it, which then silently get shift-clicks they never asked for. Release it in the same test, or set user up in a beforeEach so each test starts clean.

    Then await user.click(...), await user.type(...), await user.selectOptions(...), await user.clear(...), and make the enclosing test/it callback async. A theme's Select is usually a custom combobox rather than a native <select>, so click the option rather than reaching for selectOptions.

    On a native <select>, user.selectOptions(select, x) matches an option's text before its value attribute. RJSF stores option values as enum indices ('0', '1', …) while the text is the enum value, so select by the enum label: an old fireEvent.change(select, { target: { value: 2 } }) on enum [1, 2, 3] becomes user.selectOptions(select, '3'), not '2'.

    A test that replaces element.focus with a spy (to observe RJSF's focus-on-error) must install it after any user.type() / user.click() on that element. user-event focuses through element.focus(), so with the spy in place first the keystrokes land on document.body and the input stays empty. Have the spy still focus, as vi.fn(() => HTMLElement.prototype.focus.call(input)): focus-on-error reads a no-op focus() as the element refusing focus and moves on to the field's next control.

  • user.type() is not the only way to set a value, and reaching for fireEvent the moment it misbehaves is the common mistake. await user.click(input) followed by await user.paste(value) sets the whole value in a single input event, which is what you want whenever per-keystroke behavior gets in the way: jsdom's value sanitization for date/time/datetime-local inputs rejecting intermediate characters, an assertion counting onChange calls, or a controlled input whose value prop never updates and so reverts each keystroke. user.upload() covers type=file. See packages/core/test/StringField.test.tsx for both
  • fireEvent stays correct in a few places. Give every one you write or keep a comment saying why, so the next reader doesn't "fix" it back — a handful of older calls in @rjsf/core predate this and still lack one, so treat an uncommented call as unreviewed rather than as a precedent. Reach for it only when user-event genuinely can't express the interaction, and confirm that's true rather than assuming it:
    • user-event's own input model can't produce the value, whatever you drive it with. It only edits the types in its editableInputTypes list (text, date, datetime-local, email, month, number, password, search, tel, time, url, week), so click + paste on a type=color input silently does nothing. And every edit to a type=time input is rebuilt by its buildTimeValue, which strips non-digits and caps the result at HH:MM — '11:10:12' becomes '11:59' — so a seconds-precision time can only be set with fireEvent.change. Note that tabIndex={-1} is not a case of this: it only removes an element from the tab order, and a click still focuses it in a browser and in user-event, so user.click() followed by user.keyboard('{Enter}') reaches a tabIndex={-1} element's own onKeyDown guard
    • a widget rendered with a fixed value that never updates, where the re-render after each click reverts the last one — a multiple <select> needs its options selected together and reported in one change
    • a component whose behavior depends on the interaction being synchronous. Mantine's Select is the live example: its dropdown applies floating-ui's hide() middleware, jsdom lays every element out at zero size, and any await lets that recomputation set display: none so getByRole('option') finds nothing
    • fireEvent.submit when clicking the real button would focus it, blurring the focused field and firing onChange before submit; submitForm in packages/core/test/testUtils.tsx takes a forceFireEvent flag for exactly this
  • Never relax an assertion to make a conversion work — keep fireEvent and say why instead. Watch for assertions that quietly stop testing anything: a negative one (expect(onChange).not.toHaveBeenCalled()) passes just as happily when the event never reached the element, and an expect(...).not.toThrow() wrapping a now-async body can't just become await expect(promise).resolves.not.toThrow() — React routes an error thrown inside a handler to a window error event rather than rejecting the promise user-event returns, so that form passes either way. Assert on a window error listener instead, as packages/daisyui/test/DateTimeWidget.test.tsx does
  • user-event hangs under Vitest's fake timers, and neither advanceTimers nor delay: null avoids it — the wait isn't user-event's. @testing-library/react's asyncWrapper drains the microtask queue with a setTimeout(resolve, 0) after every user-event call, and only pumps the clock when it sees a global jest, which Vitest doesn't define. With the timer functions faked, that setTimeout never fires. A test that only needs the clock pinned should fake Date alone: vi.useFakeTimers({ toFake: ['Date'] })
  • Snapshot tests in @rjsf/snapshot-tests are shared across theme packages, but the snapshots themselves live with each theme they render: core's in @rjsf/snapshot-tests/test (core can't depend on the package that depends on it), the 9 themes' in their own packages. Changing a shared case or core rendering means running pnpm run test:update from the root, then reviewing all 10 diffs

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.