简体   繁体   中英

Running into a Jest/enzyme error “Popper: Invalid reference or popper argument provided.”

I wrote a tooltip using popperjs 2.2.1, and jest/enzyme tests. However, I get the following error:

Error: Cannot read property 'split' of undefined

console.error../../node_modules/@popperjs/core/dist/cjs/popper.js:630

Popper: Invalid reference or popper argument provided. They must be either a DOM element or virtual element.

Tried all of the recommendations in (maybe did it wrong as I am just getting into jest): https://github.com/popperjs/popper-core/issues/478 and https://github.com/popperjs/react-popper/issues/263

I recreated it in the codesandbox: https://codesandbox.io/s/tooltip-test-r8nqt?file=/src/Tooltip.spec.tsx

Any advice? tnx

You are not providing a placement property in the defaultProps object of your tests.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM