Blog / How to Test Drag-and-Drop When Your Test Passes but Nothing Moves
How-To

How to Test Drag-and-Drop When Your Test Passes but Nothing Moves

A drag-and-drop test can pass while the card never moves. Find which drag your app uses, drive it in Playwright, Cypress, or Appium, and assert the drop.

Your drag-and-drop test passes. You open the board, and the card is still sitting in To Do. CI is green and the drop handler never ran.

The test did what you told it to. It sent an input your app never listened for. Here is how to send the input your app is actually waiting for, and how to prove the card landed in Done.

What you’ll learn

  • Why a drag-and-drop test can pass while nothing on screen moved
  • How to tell native HTML5 drag from a pointer library or touch drag
  • Which Playwright, Cypress, Selenium, and Appium calls drive each one
  • How to assert the drop landed, including after a reload

Why a Drag-and-Drop Test Passes When Nothing Moved

The call returns when the input has been sent, not when the app has handled the drop. If that input never starts a drag, nothing downstream complains and the test passes. A drag is the clearest case of a general trap in end-to-end testing. A helper that returns without an error has only delivered its input.

A native drag, as the HTML Drag and Drop API on MDN lists it, is a sequence of events (dragstart, drag, dragenter, dragover, dragleave, drop, and dragend) that carries its payload in a DataTransfer object. The browser starts that sequence from real pointer input. Dispatching mousedown and mousemove events at the element does not.

On a minimal page with one draggable="true" card and one drop zone, Playwright 1.63.0 gave the same results in Chromium 153 and Firefox 155 on 2 October 2026. WebKit was not run. The whole page is below, and each handler records its event in window.log.

<div id="card" draggable="true">Ship the release</div>
<div id="column-done" style="height: 120px; border: 1px solid #888"></div>
<script>
  window.log = [];
  const done = document.getElementById('column-done');
  document.addEventListener('dragstart', (e) => { window.log.push('dragstart'); e.dataTransfer.setData('text/plain', 'card'); });
  done.addEventListener('dragover', (e) => { window.log.push('dragover'); e.preventDefault(); });
  done.addEventListener('drop', (e) => { window.log.push('drop'); e.preventDefault(); done.appendChild(document.getElementById('card')); });
</script>
What the test sendsWhat the page loggedCard moved
dragTo(), which sends real mouse inputdragstart, dragover, dropYes
dispatchEvent with mousedown, two mousemoves, mouseupNothingNo
dispatchEvent with dragstart, dragover, drop and one shared DataTransferdragstart, dragover, dropYes

Row two is the false green. A dispatched event lands whether or not anything on the page listens for it, so the test finishes and the card stays put. Think of it as a note telling the listener a hand was on the mouse. Real input is the hand.

Cypress 16.1.1 in Electron showed the same split through .trigger(). Mouse events logged nothing, and a shared DataTransfer across the three drag events moved the card, because .trigger() fires events at an element instead of driving the browser’s own input.

How to Tell Which Drag-and-Drop Your App Uses

Listen for dragstart and drag the item by hand. If the event fires, the app uses native HTML5 drag-and-drop. If the item moves and nothing logs, the app is listening for pointer, mouse, or touch events. The result sorts the app into one of three cases, and each needs a different driver.

// Paste in the browser console, then drag the item with your mouse.
document.addEventListener('dragstart', (e) => console.log('native dragstart on', e.target), true);
CaseThe app listens forLibraries you will meetHow to spot it
Native HTML5dragstart, dragover, drop, with a DataTransferPragmatic drag and drop, react-dnd (HTML5 backend), SortableJS on desktopdragstart fires when you drag by hand
Pointer or mouse eventspointerdown or mousedown, then moves, then releasednd-kit, @hello-pangea/dnd, SortableJS in its fallback mode on iOS and Chrome for AndroidNo dragstart, and the item still moves
Touch eventstouchstart, touchmove, touchenddnd-kit’s touch sensor, react-dnd’s touch backendWorks only on a touchscreen or in device emulation

The draggable attribute helps in one direction only. draggable="true" on an element at rest points to native drag, because Pragmatic drag and drop sets it when you register an element. A missing attribute proves nothing, since SortableJS is native on desktop but sets draggable only during the press.

Pointer libraries have their own wrinkle. Tutorials written for react-beautiful-dnd describe a library that is now archived and deprecated on npm. Its community fork, @hello-pangea/dnd, sets draggable="false" on its handles to block native drag, and a check for the attribute alone gives a false positive there. Test for the value "true".

How to Drive Native, Pointer, and Touch Drags

Use the tool’s real input where it has one, and dispatch events only where it does not. Playwright sits on one side of that line because it drives the browser from outside. Cypress sits on the other, running inside the page and firing events from there, the split at the root of any Playwright vs Cypress comparison. Each case below gets its own driver, and each driver gets the same assertion afterward.

1. Native HTML5: Real Input First, Events as the Fallback

In Playwright, start with dragTo(). It sends real mouse input. The browser starts the native drag and fires dragstart, dragover, and drop itself, as the table above shows.

await page.locator('#card').dragTo(page.locator('#column-done'));

To control the motion yourself, press and move by hand. Playwright’s input docs say “If your page relies on the dragover event being dispatched, you need at least two mouse moves to trigger it in all browsers.” One hover was enough on the test page in Chromium and Firefox. Keep the second anyway. The docs promise it for every browser, and it costs one line.

await page.locator('#card').hover();
await page.mouse.down();
await page.locator('#column-done').hover();
await page.locator('#column-done').hover(); // second move, per Playwright's docs
await page.mouse.up();

When you need to control the payload, or your tool only dispatches events, build one DataTransfer and fire every event through it. Playwright’s dispatchEvent docs say a DataTransfer can only be created in Chromium and Firefox, but locator.drop(), covered next, builds its own inside the page and, per its docs, works across browsers.

const dataTransfer = await page.evaluateHandle(() => new DataTransfer());
await page.locator('#card').dispatchEvent('dragstart', { dataTransfer });
await page.locator('#column-done').dispatchEvent('dragover', { dataTransfer });
await page.locator('#column-done').dispatchEvent('drop', { dataTransfer });

A file or text payload dropped in from outside the page has its own call. Playwright 1.60 added locator.drop(), which fires dragenter, dragover, and drop on the target with a synthetic DataTransfer and, per its docs, works across browsers. When the target’s dragover listener never calls preventDefault(), the call throws and the test fails instead of passing. Every drag helper should fail that loudly.

await page.locator('#dropzone').drop({
  files: { name: 'note.txt', mimeType: 'text/plain', buffer: Buffer.from('hello') },
});

Cypress has no built-in command for dragging one element onto another, and a request for native support has been open since 2023. Its .selectFile() command does take { action: 'drag-drop' }, but only for files dragged in from the operating system. Native drags between elements use the same shared-DataTransfer pattern through .trigger().

const dataTransfer = new DataTransfer();
cy.get('#card').trigger('dragstart', { dataTransfer });
cy.get('#column-done').trigger('dragover', { dataTransfer }).trigger('drop', { dataTransfer });

The community @4tw/cypress-drag-drop plugin wraps that pattern behind .drag(), but it sends drop only after the dragged element has moved during dragover, as items in a sortable list do. On the test page above, which moves the card in its drop handler, .drag() stops after five dragover events and logs an error without dropping. Its last release was in September 2025, and npm’s download API counted 200,229 downloads for the week to 29 September 2026.

Of the common end-to-end testing tools, Selenium is the one to verify on your own browser. Its Actions API sends WebDriver pointer actions, and whether the browser turns them into a native drag depends on the driver. In Firefox, Mozilla’s tracker says a drag whose pointer move lasts under 23 ms emits only mousemove and dragstart (bug 1515879, open since 2018).

The Selenium docs demonstrate drag on a jQuery UI page. That example does not exercise a native draggable element. For the browsers where the pointer path fails, keep an executeScript helper that dispatches the three events with a DataTransfer.

2. Pointer Libraries: Clear the Activation Constraint

Libraries such as dnd-kit can require an activation constraint before a drag starts. Its pointer sensor takes a distance constraint or a delay constraint, and a test has to clear whichever one the app configured.

dragTo() sends a single mousemove to the target, because its steps option defaults to 1. dnd-kit spends the move that crosses its distance constraint on starting the drag, so a single move starts the drag and drops it where it began.

With dragTo(target, { steps: 10 }), the moves after activation carry the card to the target. A delay constraint also wants the button held still before the first move, and dragTo() has no option for a hold, so press, wait, then travel in steps.

const card = page.locator('#card');
const target = page.locator('#column-done');
const from = await card.boundingBox();
const to = await target.boundingBox();

await page.mouse.move(from.x + from.width / 2, from.y + from.height / 2);
await page.mouse.down();
await page.waitForTimeout(250); // press duration for a delay constraint
await page.mouse.move(to.x + to.width / 2, to.y + to.height / 2, { steps: 10 });
await page.mouse.up();

The waitForTimeout is the press duration the library asks for, and it is the only fixed wait in the snippet. Waiting for readiness belongs in the assertions, and flake from real timing is covered in how to fix flaky Playwright tests.

In Cypress, trigger the event family the library listens for, with the primary button set, because @hello-pangea/dnd and dnd-kit both check it. @hello-pangea/dnd listens for mouse events and ignores any without button: 0, moves included. dnd-kit’s pointer sensor ignores mouse events entirely and starts on .trigger('pointerdown', { button: 0, isPrimary: true }). Follow the press with moves that carry clientX and clientY, then the matching release.

Cypress’s own drag recipe gets by with a single mousemove “even though there would be dozens in a normal interaction”. Send several when the library has an activation threshold.

Where the library ships a keyboard sensor, as dnd-kit and @hello-pangea/dnd do, lifting, moving, and dropping with the keyboard is a stable way to test the reorder logic. It skips the pointer path. Keep one pointer test as well.

3. Touch: Hold, Then Move With Real Touch Points

A touch drag runs on touchstart, touchmove, and touchend, and touch implementations typically arm the drag after a hold. Android’s drag-and-drop guide describes the user starting a drag by touching and holding an item. A hold that falls short of the arming threshold fails only some of the time, the gesture-timing problem covered in why mobile end-to-end tests flake.

For mobile web, dispatch the touch events with touch points, following Playwright’s touch-events guide. A bare dispatchEvent('touchstart') carries no touch points, because a constructed TouchEvent gets an empty touches list by default. Any handler that reads event.touches[0].clientX throws.

// In the test file: test.use({ ...devices['Pixel 7'] });
const at = (x, y) => [{ identifier: 0, clientX: x, clientY: y }];
const tile = page.locator('#tile');
const from = await tile.boundingBox();
const to = await page.locator('#slot-2').boundingBox();
const [x0, y0] = [from.x + from.width / 2, from.y + from.height / 2];
const [x1, y1] = [to.x + to.width / 2, to.y + to.height / 2];

await tile.dispatchEvent('touchstart', { touches: at(x0, y0), changedTouches: at(x0, y0) });
await page.waitForTimeout(300); // the hold that arms the drag
for (let i = 1; i <= 4; i++) {
  const [x, y] = [x0 + ((x1 - x0) * i) / 4, y0 + ((y1 - y0) * i) / 4];
  await tile.dispatchEvent('touchmove', { touches: at(x, y), changedTouches: at(x, y) });
}
await tile.dispatchEvent('touchend', { touches: [], changedTouches: at(x1, y1) });

Playwright’s docs warn that dispatchEvent() does not set Event.isTrusted, so an app that checks it needs the check disabled for the test. For native iOS and Android apps, drive the platform instead of dispatching events.

  • Android: mobile: dragGesture requires endX and endY, and mobile: longClickGesture takes a duration in milliseconds, 500 by default, per the UiAutomator2 driver docs.
  • iOS: mobile: dragFromToForDuration takes duration, fromX, fromY, toX, and toY, and mobile: touchAndHold takes a duration in seconds, per the XCUITest driver docs.
  • Either platform: A W3C Actions touch sequence of pointerDown, pause, pointerMove, and pointerUp.

TLDR: Prefer real input, fall back to a shared DataTransfer, give pointer libraries enough moves (and a hold, if asked), and give touch handlers real touch points.

Tired of Debugging Flaky Tests?

Describe the flow in plain English. Pie works from what is on screen.

How to Assert That the Drop Landed

Assert the application’s new state, never that the drag call ran. Check what the user cares about, such as the card in the Done column, the new list order, and whether that order survives a reload.

const done = page.locator('#column-done');
await expect(done).toContainText('Ship the release');
await expect(page.locator('#column-todo')).not.toContainText('Ship the release');

// A UI that snaps back after a refresh fails here.
await page.reload();
await expect(done).toContainText('Ship the release');

// For a reorder, assert the whole list in order.
await expect(page.locator('#list > li')).toHaveText(['B', 'A', 'C']);

These are Playwright’s auto-retrying assertions, which keep checking until the text matches or the timeout passes. That matters for drops, because a card often animates into place and a one-shot read of the DOM races the animation. The reload step is the same move as fetching a login code at its source in how to test 2FA and OTP flows. Both check the system of record, not the surface.

Every locator in these snippets (#column-done, #card) is also a place the suite breaks when someone renames an ID or swaps a library. The drag test needs its locators. The flows before and after it, such as opening the board or creating the card, can live in Pie’s autonomous QA platform instead. Its Custom Tests are written in plain English, so your team can author supported tests without maintaining selectors.

Test the Drop, Not the Drag

A passing drag call proves that an input went out. It says nothing about where the card ended up, and the card can sit in To Do the whole time.

What works is boring and specific. Match the input to the implementation, then assert what the page shows after a reload. Selectors are what is left to maintain, and they rot the day someone renames a class.

Keep your locators for one real drag test per feature. Write the tests around it in plain English with Pie, and a renamed class has far less to break.

Stop Maintaining Selectors

Hand the flows around your drag test to Pie. Skip the selector upkeep.

Frequently Asked Questions

The test sent an input the app never listened for, and the call still returned cleanly. Dispatching mousedown and mousemove events at an element does not start a native browser drag. Assert the item's new position or state after the drop, because the call's return proves nothing.
In Chromium and Firefox, dragTo sends real mouse input, so native HTML5 drags start on their own. A card that stays put points to a pointer library that needs several moves. Raise the steps option on dragTo, or press, hold, and travel with mouse.move when it also wants a hold.
WebDriver pointer actions do not always become a native browser drag, and Mozilla's tracker has listed the Firefox case as open since 2018. Verify on your driver version, and fall back to an executeScript helper that dispatches dragstart, dragover, and drop with a DataTransfer.
Cypress fires events with .trigger() instead of moving a real pointer. For HTML5 drags, pass one DataTransfer to dragstart, dragover, and drop. For pointer libraries, trigger the press, several moves, and the release in the library's event family, with button 0. The @4tw/cypress-drag-drop plugin's .drag() fires drop only after the item moves mid-drag.

For mobile web, dispatch touchstart, touchmove, and touchend with real touch points, and hold before the first move. For native apps, Appium offers the dragGesture command on Android and dragFromToForDuration on iOS.

Assert the final state after the drop.

Add a document listener for dragstart in the browser console and drag the item by hand. If it logs, the app uses native HTML5 drag-and-drop. If the item moves and nothing logs, the app listens for pointer, mouse, or touch events, and the test needs a different driver.
Pie Custom Tests are written in plain English, so your team can author supported tests without maintaining selectors. When a button's ID or text changes, the AI can still identify the correct element using context, position, and function. Pie calls this self-healing.
Adithya Aggarwal
Adithya Aggarwal
CTO & Co-founder at Pie

Eight years building search and delivery systems at Amazon. The kind of scale where flaky tests block billion-dollar releases. Now CTO at Pie, building AI agents that adapt when your UI changes. LinkedIn →