From 168e557f22c4684b7b6bbd45ad7f74dc6ac93add Mon Sep 17 00:00:00 2001 From: Jon Jensen Date: Thu, 5 Jan 2023 16:44:15 -0700 Subject: [PATCH] test(react-router-dom): streamline jsdom submitter bug workaround MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Work around the submitter bug in just one place, and link to my jsdom PR which will fix it, so that the workaround can be removed sooner rather than later 🤞 This workaround refactor also establishes a pattern for other jsdom bug polyfills which will be landing in forthcoming RR PRs (the bugs aren't relevant in the current test suite, but will be in the PRs 😅) --- .changeset/slow-trees-notice.md | 5 ++ contributors.yml | 1 + .../__tests__/data-browser-router-test.tsx | 77 ++----------------- .../polyfills/SubmitEvent.submitter.ts | 26 +++++++ packages/react-router-dom/__tests__/setup.ts | 2 + 5 files changed, 41 insertions(+), 70 deletions(-) create mode 100644 .changeset/slow-trees-notice.md create mode 100644 packages/react-router-dom/__tests__/polyfills/SubmitEvent.submitter.ts diff --git a/.changeset/slow-trees-notice.md b/.changeset/slow-trees-notice.md new file mode 100644 index 0000000000..5c235db5cb --- /dev/null +++ b/.changeset/slow-trees-notice.md @@ -0,0 +1,5 @@ +--- +"react-router-dom": patch +--- + +Streamline jsdom bug workaround in tests diff --git a/contributors.yml b/contributors.yml index 866b89355d..d8b827c9b7 100644 --- a/contributors.yml +++ b/contributors.yml @@ -74,6 +74,7 @@ - JakubDrozd - janpaepke - jasonpaulos +- jenseng - JesusTheHun - jimniels - jmargeta diff --git a/packages/react-router-dom/__tests__/data-browser-router-test.tsx b/packages/react-router-dom/__tests__/data-browser-router-test.tsx index b1c8ebace3..7148b45192 100644 --- a/packages/react-router-dom/__tests__/data-browser-router-test.tsx +++ b/packages/react-router-dom/__tests__/data-browser-router-test.tsx @@ -1506,14 +1506,7 @@ function testDomRouter( function Comp() { let location = useLocation(); return ( -
{ - // jsdom doesn't handle submitter so we add it here - // See https://github.com/jsdom/jsdom/issues/3117 - // @ts-expect-error - e.nativeEvent.submitter = e.currentTarget.querySelector("button"); - }} - > +

{location.pathname + location.search}