question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error: `initialFocus` refers to no known node in Enzyme

See original GitHub issue

I have consumed this component and it works fine. while writing test cases i m getting this error:

Error: initialFocus refers to no known node

I actually passed a selector to initialFocus prop. I tried passing a well mounted node which already exists (tested by querying), but i m still getting the same error. Any idea why is this happening?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

12reactions
crutchcorncommented, Feb 14, 2020

I’ve found that the following mock works sufficiently for my usage within testing for the component in Jest:

jest.mock('focus-trap', () => {
  const trap = {
    activate: () => trap,
    deactivate: () => trap,
    pause: () => {},
    unpause: () => {}
  };
  return () => trap;
});
1reaction
mperrotticommented, Apr 19, 2018

I’m having this same problem, and the selector I’m passing is for a focusable element - an <input />. Maybe there could be an option to suppress this error from being thrown?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Developers - Error: `initialFocus` refers to no known node in Enzyme -
I have consumed this component and it works fine. while writing test cases i m getting this error: Error: initialFocus refers to no...
Read more >
Why I Re-Wrote the focus-trap-react Test Suite Using React ...
The problem here is that while we're asserting that this function was called, we're really not saying anything about the actual user ...
Read more >
Jest error: "Your focus-trap must have at least one container ...
I can't fix a bug in a component test. I tried to add focus on the element to the test code: await waitFor(()...
Read more >
contains(nodeOrNodes) · Enzyme - GitHub Pages
contains(nodeOrNodes) => Boolean. Returns whether or not all given react elements match elements in the render tree. It will determine if an element...
Read more >
Metro Ethernet Forum (MEF) - IEEE 802
Scoping the Problem ... No commitment on when/how – initial focus is “Phase I” ... Well-known addresses default to MEF-defined but are configurable!...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found