Open Nokel81 opened 5 months ago
FYI I have found a workaround for the time being
import type { Backend, BackendFactory } from "dnd-core";
import { HTML5Backend } from "react-dnd-html5-backend";
const HotbarBackend: BackendFactory = (manager, globalContext, configuration) => {
const base = HTML5Backend(manager, globalContext, configuration) as Backend & {
handleTopDrop: (e: DragEvent) => void;
};
const internalHandleTopDrop = base.handleTopDrop;
base.handleTopDrop = (e: DragEvent) => {
try {
internalHandleTopDrop(e);
} catch (error) {
if (process.env.JEST_WORKER_ID) {
if (process.env.DEBUG) {
console.warn(error);
}
} else {
throw error;
}
}
};
return base;
};
Describe the bug I am trying to write a unit test to verify that some
useDrag
cannot be dragged under some conditions however the way that I have found to test throws anInvariant Violation: Cannot call hover while not dragging.
error.Reproduction
This is how I do the test
Expected behavior Nothing to been thrown but also not calls
drop
.