colinrobertbrooks / react-beautiful-dnd-test-utils

Test utils for react-beautiful-dnd built with react-testing-library 🧤
https://www.npmjs.com/package/react-beautiful-dnd-test-utils
MIT License
32 stars 14 forks source link

userEvent__default.default.keyboard is not a function #15

Closed daniele-zurico closed 2 years ago

daniele-zurico commented 2 years ago

Hi I'm trying to use this library however it keeps complaining about:

` TypeError: userEvent__default.default.keyboard is not a function

  at node_modules/react-beautiful-dnd-test-utils/dist/index.cjs.js:164:67
  at step (node_modules/react-beautiful-dnd-test-utils/dist/index.cjs.js:60:23)
  at Object.next (node_modules/react-beautiful-dnd-test-utils/dist/index.cjs.js:41:53)
  at node_modules/react-beautiful-dnd-test-utils/dist/index.cjs.js:34:71
  at __awaiter (node_modules/react-beautiful-dnd-test-utils/dist/index.cjs.js:30:12)
  at handleMovementInDirection (node_modules/react-beautiful-dnd-test-utils/dist/index.cjs.js:158:70)
  at node_modules/react-beautiful-dnd-test-utils/dist/index.cjs.js:117:56`

Npm versions:

"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^11.1.0",
"@testing-library/user-event": "^12.1.10",
"react-beautiful-dnd-test-utils": "^4.1.0",

Test:

it("should call onDragEnd handler", async () => {
    const { container } = render(<App /> );
   // i know I can do better but is a quick test
    const toggle = getByTestId(container, "draggable-component-Toggle");
    await makeDnd({
      getDragElement: () => toggle,
      direction: DND_DIRECTION_DOWN,
      positions: 2,
    });
  });

what I'm missing?

colinrobertbrooks commented 2 years ago

See https://github.com/colinrobertbrooks/react-beautiful-dnd-test-utils/pull/13 (tl;dr: update @testing-library/user-event to v13).

colinrobertbrooks commented 2 years ago

I noticed we need to update the peerDependency for @testing-library/user-event; I'll do this tomorrow.

colinrobertbrooks commented 2 years ago

Updated in v4.1.1. 🚢