Skip to content

perf: replace manual fireEvent loop with shared wrapFireEventMethods#16

Merged
Lojhan merged 2 commits intomainfrom
perf/testing-core-improvements
Apr 5, 2026
Merged

perf: replace manual fireEvent loop with shared wrapFireEventMethods#16
Lojhan merged 2 commits intomainfrom
perf/testing-core-improvements

Conversation

@Lojhan
Copy link
Copy Markdown
Collaborator

@Lojhan Lojhan commented Apr 5, 2026

Summary

Replaces the manual for loop in react-testing.ts with the new wrapFireEventMethods() helper exported by @pokujs/dom.

Before

~20 lines of boilerplate that iterated Object.keys(baseFireEventInstance), copied non-function properties as-is, and wrapped functions with an act() call.

After

wrapFireEventMethods(
  wrappedFireEvent as unknown as Record<string, unknown>,
  baseFireEventInstance as unknown as Record<string, unknown>,
  (invoke: () => unknown) => {
    let result: unknown;
    act(() => { result = invoke(); });
    return result;
  }
);

Behaviour is identical — act() still wraps every dispatched event. The change eliminates duplicated boilerplate that is now shared with @pokujs/vue.

Lojhan added 2 commits April 5, 2026 18:23
Use the new wrapFireEventMethods() helper from @pokujs/dom instead of the
hand-rolled for loop that copied+wrapped each fireEvent method. The helper
encapsulates the iteration pattern; the act()-based wrapper is identical
in behaviour to the previous code.
@Lojhan Lojhan merged commit 1f86e4d into main Apr 5, 2026
10 checks passed
@Lojhan Lojhan deleted the perf/testing-core-improvements branch April 5, 2026 21:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant