Skip to content

'undefined' is not a valid selector #152

@dosomder

Description

@dosomder

Since upgrading nwsapi to 2.2.21, I have the following problem which causes tests to fail. With 2.2.20, there is no problem.

Following code snippet from jest test:

    render(<ColumnFilter label="testFilter" filterKey={TestFilter.KEY} />);

    // activate input field
    await userEvent.click(screen.getByRole("button"));

I get the following error:

    SyntaxError: 'undefined' is not a valid selector

      156 |
      157 |     // activate input field
    > 158 |     await userEvent.click(screen.getByRole("button"));

     at emit (node_modules/nwsapi/src/nwsapi.js:656:17)
      at compileSelector (node_modules/nwsapi/src/nwsapi.js:1479:11)
      at compile (node_modules/nwsapi/src/nwsapi.js:866:16)
      at collect (node_modules/nwsapi/src/nwsapi.js:1703:22)
      at _querySelectorAll (node_modules/nwsapi/src/nwsapi.js:1661:36)
      at Object._querySelector [as first] (node_modules/nwsapi/src/nwsapi.js:1603:14)
      at HTMLButtonElementImpl.querySelector (node_modules/jsdom/lib/jsdom/living/nodes/ParentNode-impl.js:69:44)
      at HTMLButtonElement.querySelector (node_modules/jsdom/lib/jsdom/living/generated/Element.js:1094:58)
      at Array.Resolver (eval at compile (node_modules/nwsapi/src/nwsapi.js:882:17), <anonymous>:3:67)
      at match_assert (node_modules/nwsapi/src/nwsapi.js:1527:13)
      at Object._matches [as match] (node_modules/nwsapi/src/nwsapi.js:1592:16)
      at exports.matchesDontThrow (node_modules/jsdom/lib/jsdom/living/helpers/selectors.js:29:36)
      at matches (node_modules/jsdom/lib/jsdom/living/helpers/style-rules.js:172:10)
      at node_modules/jsdom/lib/jsdom/living/helpers/style-rules.js:109:18
          at Array.forEach (<anonymous>)
      at handleSheet (node_modules/jsdom/lib/jsdom/living/helpers/style-rules.js:100:13)
          at Array.forEach (<anonymous>)
      at forEachMatchingSheetRuleOfElement (node_modules/jsdom/lib/jsdom/living/helpers/style-rules.js:120:11)
      at exports.getDeclarationForElement (node_modules/jsdom/lib/jsdom/living/helpers/style-rules.js:156:3)
      at window.getComputedStyle (node_modules/jsdom/lib/jsdom/browser/Window.js:901:32)
      at isInaccessible (node_modules/@testing-library/dom/dist/role-helpers.js:67:14)
      at node_modules/@testing-library/dom/dist/queries/role.js:185:63
          at Array.filter (<anonymous>)
      at queryAllByRole (node_modules/@testing-library/dom/dist/queries/role.js:184:6)
      at node_modules/@testing-library/dom/dist/query-helpers.js:74:17
      at node_modules/@testing-library/dom/dist/query-helpers.js:52:17
      at node_modules/@testing-library/dom/dist/query-helpers.js:95:19
      at Object.<anonymous> (tests/client/filter/Filter.test.tsx:176:34)

When I print the html with screen.debug(), this is the output:

   <body>
      <div>
        <div
          aria-disabled="false"
          aria-expanded="false"
          class="ui multiple search dropdown column-filter "
          id="test"
          role="combobox"
        >
          <a
            class="ui label nonClickable"
            value="a2"
          >
            b2
            <i
              aria-hidden="true"
              class="delete icon"
            />
          </a>
          <input
            aria-autocomplete="list"
            autocomplete="off"
            class="search"
            tabindex="0"
            type="text"
            value=""
          />
          <span
            class="sizer"
          />
          <button
            class="ui mini icon button filter-icon-inverted"
            id="test-filter-button"
          >
            <i
              aria-hidden="true"
              class="filter icon"
            />
          </button>
          <div
            aria-multiselectable="true"
            class="menu transition"
            role="listbox"
          >
            <div
              class="message"
            >
              No results found.
            </div>
          </div>
        </div>
      </div>
    </body>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions