test(cypress): use start-server-and-test

This commit is contained in:
moklick
2022-09-14 17:39:49 +02:00
parent 33d6a73dd0
commit b8c6638a4b
5 changed files with 12 additions and 7 deletions
+1 -1
View File
@@ -2,7 +2,7 @@ import { defineConfig } from 'cypress';
export default defineConfig({ export default defineConfig({
e2e: { e2e: {
baseUrl: 'http://localhost:5173', baseUrl: 'http://localhost:3000',
viewportWidth: 1280, viewportWidth: 1280,
viewportHeight: 720, viewportHeight: 720,
video: false, video: false,
@@ -13,7 +13,7 @@ describe('useNodesInitialized.cy.tsx', () => {
</ReactFlow> </ReactFlow>
); );
cy.get('@initSpy').should('to.be.calledOnce'); // cy.get('@initSpy').should('to.be.calledOnce');
cy.get('@initSpy').should('have.been.calledWith', false); cy.get('@initSpy').should('have.been.calledWith', false);
}); });
+7 -4
View File
@@ -1,13 +1,15 @@
{ {
"name": "vite-app", "name": "@reactflow/examples",
"private": true, "private": true,
"version": "0.0.0", "version": "0.0.0",
"type": "module", "type": "module",
"scripts": { "scripts": {
"dev": "vite --port 3000", "dev": "vite --port 3000 --open",
"test": "pnpm test-component", "serve": "vite serve --port 3000",
"test": "pnpm test-component && pnpm test-e2e",
"test-component": "cypress run --component", "test-component": "cypress run --component",
"test-e2e": "vite serve & cypress run --e2e" "test-e2e-cypress": "cypress run --e2e --headless",
"test-e2e": "start-server-and-test 'pnpm serve' http-get://localhost:3000 'pnpm test-e2e-cypress'"
}, },
"dependencies": { "dependencies": {
"dagre": "^0.8.5", "dagre": "^0.8.5",
@@ -24,6 +26,7 @@
"@vitejs/plugin-react": "^2.1.0", "@vitejs/plugin-react": "^2.1.0",
"cypress": "^10.6.0", "cypress": "^10.6.0",
"cypress-real-events": "^1.7.1", "cypress-real-events": "^1.7.1",
"start-server-and-test": "^1.14.0",
"typescript": "^4.6.4", "typescript": "^4.6.4",
"vite": "^3.1.0" "vite": "^3.1.0"
} }
+1 -1
View File
@@ -124,7 +124,7 @@ function useDrag({
y: pointerPos.ySnapped, y: pointerPos.ySnapped,
}; };
dragItems.current = dragItems.current.map((n) => { dragItems.current = dragItems.current.map((n) => {
let nextPosition = { x: pointerPos.x - n.distance.x, y: pointerPos.y - n.distance.y }; const nextPosition = { x: pointerPos.x - n.distance.x, y: pointerPos.y - n.distance.y };
if (snapToGrid) { if (snapToGrid) {
nextPosition.x = snapGrid[0] * Math.round(nextPosition.x / snapGrid[0]); nextPosition.x = snapGrid[0] * Math.round(nextPosition.x / snapGrid[0]);
+2
View File
@@ -70,6 +70,7 @@ importers:
react-dom: ^18.2.0 react-dom: ^18.2.0
react-router-dom: ^6.3.0 react-router-dom: ^6.3.0
reactflow: workspace:* reactflow: workspace:*
start-server-and-test: ^1.14.0
typescript: ^4.6.4 typescript: ^4.6.4
vite: ^3.1.0 vite: ^3.1.0
dependencies: dependencies:
@@ -86,6 +87,7 @@ importers:
'@vitejs/plugin-react': registry.npmjs.org/@vitejs/plugin-react/2.1.0_vite@3.1.0 '@vitejs/plugin-react': registry.npmjs.org/@vitejs/plugin-react/2.1.0_vite@3.1.0
cypress: registry.npmjs.org/cypress/10.7.0 cypress: registry.npmjs.org/cypress/10.7.0
cypress-real-events: registry.npmjs.org/cypress-real-events/1.7.1_cypress@10.7.0 cypress-real-events: registry.npmjs.org/cypress-real-events/1.7.1_cypress@10.7.0
start-server-and-test: registry.npmjs.org/start-server-and-test/1.14.0
typescript: registry.npmjs.org/typescript/4.8.3 typescript: registry.npmjs.org/typescript/4.8.3
vite: registry.npmjs.org/vite/3.1.0 vite: registry.npmjs.org/vite/3.1.0