epicweb-dev / epic-stack

This is a Full Stack app starter with the foundational things setup and configured for you to hit the ground running on your next EPIC idea.
https://www.epicweb.dev/epic-stack
MIT License
4.47k stars 368 forks source link

Tests failing on a fresh install due to SyntaxErrors #707

Closed pasimuno-ako closed 4 months ago

pasimuno-ako commented 5 months ago

On Node v20.11.1, when running the tests on a freshly-cloned Epic stack, I immediately get failures.

✓ app/utils/misc.error-message.test.ts (3)
❯ app/utils/misc.use-double-check.test.tsx (3)
 × prevents default on the first click, and does not on the second
 × blurring the button starts things over
 × hitting "escape" on the input starts things over
❯ app/routes/users+/$username.test.tsx (2) 2073ms
 × The user profile when not logged in as self 1042ms
 × The user profile when logged in as self 1020ms
✓ app/routes/_auth+/auth.$provider.callback.test.ts (8)

 FAIL  app/utils/misc.use-double-check.test.tsx > prevents default on the first click, and does not on the second
 FAIL  app/utils/misc.use-double-check.test.tsx > blurring the button starts things over
 FAIL  app/utils/misc.use-double-check.test.tsx > hitting "escape" on the input starts things over
SyntaxError: 'h1' is not a valid selector
 ❯ emit node_modules/nwsapi/src/nwsapi.js:557:17
 ❯ Object._matches [as match] node_modules/nwsapi/src/nwsapi.js:1397:9
 ❯ HTMLOutputElementImpl.ElementImpl.matches node_modules/jsdom/lib/jsdom/living/nodes/Element-impl.js:592:18
 ❯ HTMLOutputElement.matches node_modules/jsdom/lib/jsdom/living/generated/Element.js:655:34
 ❯ node_modules/@testing-library/dom/dist/role-helpers.js:143:19
 ❯ getImplicitAriaRoles node_modules/@testing-library/dom/dist/role-helpers.js:86:9
 ❯ node_modules/@testing-library/dom/dist/queries/role.js:134:65
 ❯ queryAllByRole node_modules/@testing-library/dom/dist/queries/role.js:123:28
 ❯ node_modules/@testing-library/dom/dist/query-helpers.js:74:17

 FAIL  app/routes/users+/$username.test.tsx > The user profile when not logged in as self
SyntaxError: '*[role~="heading"],h1,h2,h3,h4,h5,h6' is not a valid selector
 ❯ emit node_modules/nwsapi/src/nwsapi.js:557:17
 ❯ Object._querySelectorAll [as select] node_modules/nwsapi/src/nwsapi.js:1501:9
 ❯ HTMLBodyElementImpl.querySelectorAll node_modules/jsdom/lib/jsdom/living/nodes/ParentNode-impl.js:78:26
 ❯ HTMLBodyElement.querySelectorAll node_modules/jsdom/lib/jsdom/living/generated/Element.js:1119:58
 ❯ queryAllByRole node_modules/@testing-library/dom/dist/queries/role.js:121:31
 ❯ node_modules/@testing-library/dom/dist/query-helpers.js:74:17
 ❯ node_modules/@testing-library/dom/dist/query-helpers.js:52:17
 ❯ node_modules/@testing-library/dom/dist/query-helpers.js:95:19
 ❯ container.container node_modules/@testing-library/dom/dist/query-helpers.js:87:14
 ❯ runWithExpensiveErrorDiagnosticsDisabled node_modules/@testing-library/dom/dist/config.js:47:12

FAIL  app/routes/users+/$username.test.tsx > The user profile when logged in as self
SyntaxError: '*[role~="heading"],h1,h2,h3,h4,h5,h6' is not a valid selector
 ❯ emit node_modules/nwsapi/src/nwsapi.js:557:17
 ❯ Object._querySelectorAll [as select] node_modules/nwsapi/src/nwsapi.js:1501:9
 ❯ HTMLBodyElementImpl.querySelectorAll node_modules/jsdom/lib/jsdom/living/nodes/ParentNode-impl.js:78:26
 ❯ HTMLBodyElement.querySelectorAll node_modules/jsdom/lib/jsdom/living/generated/Element.js:1119:58
 ❯ queryAllByRole node_modules/@testing-library/dom/dist/queries/role.js:121:31
 ❯ node_modules/@testing-library/dom/dist/query-helpers.js:74:17
 ❯ node_modules/@testing-library/dom/dist/query-helpers.js:52:17
 ❯ node_modules/@testing-library/dom/dist/query-helpers.js:95:19
 ❯ container.container node_modules/@testing-library/dom/dist/query-helpers.js:87:14
 ❯ runWithExpensiveErrorDiagnosticsDisabled node_modules/@testing-library/dom/dist/config.js:47:12

Some people were having issues with the nwsapi library where the error is coming from, and they were suggesting to downgrade to 2.2.2.

Upon checking, I am using nwsapi@2.2.8, a dependency of jsdom@24.0.0.

Here's another issue with the same cause: https://github.com/dperini/nwsapi/issues/108

EDIT 1: The temporary fix is to add this to your package.json, delete node_modules (and probably package-lock.json too), and reinstall everything with npm i.

"overrides": {
  "nwsapi": "2.2.2"
}

Though @eps1lon says 2.2.7 works.

eps1lon commented 5 months ago

Fixed in latest nwsapi@2.2.9

kentcdodds commented 5 months ago

Thanks!

I'll be happy to accept a PR that upgrades our deps!