![Create React App Officially Deprecated Amid React 19 Compatibility Issues](https://cdn.sanity.io/images/cgdhsj6q/production/04fa08cf844d798abc0e1a6391c129363cc7e2ab-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
@4tw/cypress-drag-drop
Advanced tools
@4tw/cypress-drag-drop is a Cypress plugin that allows you to easily simulate drag-and-drop interactions in your end-to-end tests. This can be particularly useful for testing applications with complex UI interactions that involve dragging and dropping elements.
Basic Drag and Drop
This feature allows you to drag an element with the ID 'drag-element' and drop it onto an element with the ID 'drop-target'.
cy.get('#drag-element').drag('#drop-target');
Drag and Drop with Offset
This feature allows you to drag an element with the ID 'drag-element' and drop it onto an element with the ID 'drop-target' with specific offsets for the X and Y coordinates.
cy.get('#drag-element').drag('#drop-target', { offsetX: 10, offsetY: 20 });
Drag and Drop with Force
This feature allows you to force the drag-and-drop action even if the element is not visible or interactable.
cy.get('#drag-element').drag('#drop-target', { force: true });
cypress-real-events is a Cypress plugin that provides real user events like click, double-click, and drag-and-drop. It uses the native browser events to simulate user interactions, making it more reliable for certain types of tests compared to @4tw/cypress-drag-drop.
cypress-drag-drop is another Cypress plugin for drag-and-drop interactions. It offers similar functionality to @4tw/cypress-drag-drop but may have different API methods and options for customization.
A cypress child command for drag'n'drop support.
Install using npm:
npm install --save-dev @4tw/cypress-drag-drop
or yarn
yarn add --dev @4tw/cypress-drag-drop
Before Cypress is loaded (usually in your commands.js
) put the following line:
require('@4tw/cypress-drag-drop')
Or, if you are using ES module syntax:
import '@4tw/cypress-drag-drop'
This will register the drag
command.
If you're using TypeScript, the following configuration in a tsconfig.json
{
"compilerOptions": {
"types": ["cypress", "@4tw/cypress-drag-drop"]
}
}
The drag
command is a child command.
The command only accepts elements.
As the drop target simply pass a selector as string.
In your cypress spec use the command as follows:
describe('Dragtest', () => {
it('should dragndrop', () => {
cy.visit('/yourpage')
cy.get('.sourceitem').drag('.targetitem')
})
})
The command also accepts all the common options.
describe('Dragtest', () => {
it('should dragndrop', () => {
cy.visit('/yourpage')
cy.get('.sourceitem').drag('.targetitem', options)
})
})
The move
command is a child command.
The command only accepts elements.
Define x
and y
as an object parameter to move the element in x- and y-position relative to the elements current position.
In your cypress spec use the command as follows:
describe('Dragtest', () => {
it('should dragndrop', () => {
cy.visit('/yourpage')
cy.get('.sourceitem').move({ x: 100, y: 100 })
})
})
The command also accepts all the common options.
describe('Dragtest', () => {
it('should dragndrop', () => {
cy.visit('/yourpage')
cy.get('.sourceitem').move({ x: 100, y: 100, ...options })
})
})
Decide at which position the element should be grabbed, moved and dropped.
Possible values are topLeft, top, topRight, left, center, right, bottomLeft, bottom, and bottomRight.
The default position is top
.
See https://docs.cypress.io/api/commands/trigger.html#Arguments for more information.
Force the drag'n'drop interaction. Meaning that the grabbing, moving and dropping is forced. See https://docs.cypress.io/guides/core-concepts/interacting-with-elements.html#Forcing for more information.
You can also use other options defined by default by Cypress, like: ctrlKey
, log
, timeout
...
See https://docs.cypress.io/api/commands/click.html#Arguments for more information.
The plugin itself is implemented in the index.js
file.
The tests can be run using cypress:
yarn test
The test fixtures are under src/examples/
. Using the setExample
cypress command
the fixture is loaded and ready to run tests on. The first attribute in the setExample
command
is the name of the fixture which needs to be the filename of the component.
cy.setExample('NameOfTheComponent')
Release a new version of this package:
yarn run release
[1.8.1] - 2021-09-01
FAQs
A cypress child command for drag'n'drop support.
We found that @4tw/cypress-drag-drop demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 8 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.