Hoy probé la rama Cypress que desarrollaste y funciona bien
Empecé a probar el front del servicio Tp-Link y puedo avanzar bien. La parte de fixture/mock de las llamadas backend es un poco más compleja, pero también funciona.
Creo que realmente deberíamos ponernos en modo TDD para escribir este tipo de pruebas.
Para la parte de la API backend, ¿queremos probar solo el core? El resto (servicios) está demasiado vinculado al hardware, por lo que queremos mockear todo, ¿es así?
Creo que hay un error entre la documentación y el comando en el package.json para iniciar el servidor para las pruebas de Cypress (npm run start:cypress <=> npm run cypress:start)
Gracias por el trabajo y tengo ganas de verlo en la CI y en el coverage
Sí, será más fácil para implementar nuestras pruebas y también para validar nuestros desarrollos.
Sería bueno probar el core al máximo. Pero sí, para las interacciones con los dispositivos, es complicado, por lo que hay que intentar mockear solo los WebServices que llaman a los servicios reales.
Si lo hacemos en una página de configuración (como para el Bluetooth y la frecuencia de escaneo, que solo registra parámetros en la base de datos).
El script npm run cypress:start no debería estar en el archivo package.json de la raíz, y la documentación especifica que debes estar en la raíz de Gladys (ni en front, ni en server).
(sí, lo sé cypress:start vs start:cypress, intenté seguir la « lógica » ya existente, pero todo es modificable ).
Con mi PR, la CI ya ejecuta las pruebas (bloqueando en caso de error), solo falta la cobertura.
Gracias por probar, con @pierre-gilles habíamos acordado que yo debía probar el componente « react-select » que es un poco especial (para proporcionar la técnica a aplicar), y dejar que la comunidad juegue con él antes de hacer merge, luego hacer merge poco a poco, para evitar el efecto túnel (y admito que trabajar 5 días seguidos en ello, cansa).
@AlexTrovato ¿Crees que puedo fusionar pronto la PR de Cypress? Pienso que, como dijimos, podemos fusionarla aunque no todo esté cubierto, así al menos la estructura estará en master y podremos basarnos en ella para hacer PRs que añadan cobertura
terdieu@DUBLEM-PC-01:~/gladys-dev/requeteAPI/Gladys/front[ExpandIconSelectionScenes !]$ npm run start:cypress
> gladys-front@ start:cypress /home/terdieu/gladys-dev/requeteAPI/Gladys/front
> cross-env DEMO_MODE=false WEBSOCKET_URL=ws://localhost:1443 LOCAL_API_URL=http://localhost:1443 npm start
> gladys-front@ start /home/terdieu/gladys-dev/requeteAPI/Gladys/front
> per-env
> gladys-front@ start:development /home/terdieu/gladys-dev/requeteAPI/Gladys/front
> npm run -s dev
Build [ ] 0% (0.0s) compilingℹ 「wds」: Project is running at http://0.0.0.0:1444/
ℹ 「wds」: webpack output is served from /
ℹ 「wds」: Content not from webpack is served from /home/terdieu/gladys-dev/requeteAPI/Gladys/front/src
ℹ 「wds」: 404s will fallback to /index.html
Build [== ] 10% (0.1s) buildingBrowserslist: caniuse-lite is outdated. Please run:
npx browserslist@latest --update-db
Why you should do it regularly:
https://github.com/browserslist/browserslist#browsers-data-updating
Build [========== ] 49% (13.9s) buildingBrowserslist: caniuse-lite is outdated. Please run:
npx browserslist@latest --update-db
Why you should do it regularly:
https://github.com/browserslist/browserslist#browsers-data-updating
Compiled successfully!
You can view the application in browser.
Local: http://0.0.0.0:1444
On Your Network: http://172.29.212.22:1444
Y finalmente intenté lanzar Cypress (intento desde el front y la raíz de Gladys).
terdieu@DUBLEM-PC-01:~/gladys-dev/requeteAPI/Gladys[ExpandIconSelectionScenes !]$ npm run cypress:open
> gladys@4.8.3 cypress:open /home/terdieu/gladys-dev/requeteAPI/Gladys
> cd front && npm run cypress:open
> gladys-front@ cypress:open /home/terdieu/gladys-dev/requeteAPI/Gladys/front
> cypress open --config-file cypress/cypress.json
It looks like this is your first time using Cypress: 6.9.1
✖ Verifying Cypress can run /home/terdieu/.cache/Cypress/6.9.1/Cypress
→ Cypress Version: 6.9.1
Cypress verification timed out.
This command failed with the following output:
/home/terdieu/.cache/Cypress/6.9.1/Cypress/Cypress --no-sandbox --smoke-test --ping=156
----------
Command timed out after 30000 milliseconds: /home/terdieu/.cache/Cypress/6.9.1/Cypress/Cypress --no-sandbox --smoke-test --ping=156
Timed out
----------
Platform: linux (Ubuntu - 20.04)
Cypress Version: 6.9.1
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! gladys-front@ cypress:open: `cypress open --config-file cypress/cypress.json`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the gladys-front@ cypress:open script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/terdieu/.npm/_logs/2022-04-12T08_25_08_213Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! gladys@4.8.3 cypress:open: `cd front && npm run cypress:open`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the gladys@4.8.3 cypress:open script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?
npm ERR! A complete log of this run can be found in:
npm ERR! /home/terdieu/.npm/_logs/2022-04-12T08_25_08_243Z-debug.log
Luego intenté seguir el enlace que das en tus diapositivas:
Después intenté reiniciar la parte del servidor y del frontend también, pero nada.
No tengo ningún cliente en Xlaunch. ¿Algún puerto en particular que deba abrir?
Bueno, ya está hecho, entonces añade cosas, al menos intenta realmente lanzarlo ^^
Pero se bloquea ^^ - Lo miraré esta noche al llegar ^^ :
terdieu@DUBLEM-PC-01:~/gladys-dev/requeteAPI/Gladys[ExpandIconSelectionScenes !]$ npm run cypress
> gladys@4.8.3 cypress /home/terdieu/gladys-dev/requeteAPI/Gladys
> run-p start:cypress cypress:open
> gladys@4.8.3 cypress:open /home/terdieu/gladys-dev/requeteAPI/Gladys
> cd front && npm run cypress:open
> gladys@4.8.3 start:cypress /home/terdieu/gladys-dev/requeteAPI/Gladys
> run-p start-server:cypress start-front:cypress
> gladys-front@ cypress:open /home/terdieu/gladys-dev/requeteAPI/Gladys/front
> cypress open --config-file cypress/cypress.json
> gladys@4.8.3 start-server:cypress /home/terdieu/gladys-dev/requeteAPI/Gladys
> cd server && npm run cypress
> gladys@4.8.3 start-front:cypress /home/terdieu/gladys-dev/requeteAPI/Gladys
> cd front && npm run start:cypress
> gladys-server@ cypress /home/terdieu/gladys-dev/requeteAPI/Gladys/server
> npm run cypress:clean && npm run cypress:start
> gladys-front@ start:cypress /home/terdieu/gladys-dev/requeteAPI/Gladys/front
> cross-env DEMO_MODE=false WEBSOCKET_URL=ws://localhost:1443 LOCAL_API_URL=http://localhost:1443 npm start
It looks like this is your first time using Cypress: 6.9.1
⠹ Verifying Cypress can run /home/terdieu/.cache/Cypress/6.9.1/Cypress
> gladys-server@ cypress:clean /home/terdieu/gladys-dev/requeteAPI/Gladys/server
> npx rimraf ./gladys-cypress.db*
> gladys-front@ start /home/terdieu/gladys-dev/requeteAPI/Gladys/front
> per-env
⠴ Verifying Cypress can run /home/terdieu/.cache/Cypress/6.9.1/Cypress
> gladys-server@ cypress:start /home/terdieu/gladys-dev/requeteAPI/Gladys/server
> cross-env SQLITE_FILE_PATH=./gladys-cypress.db node index.js
> gladys-front@ start:development /home/terdieu/gladys-dev/requeteAPI/Gladys/front
> npm run -s dev
⠋ Verifying Cypress can run /home/terdieu/.cache/Cypress/6.9.1/Cypress
internal/modules/cjs/loader.js:1144
return process.dlopen(module, path.toNamespacedPath(filename));
^
Error: The module '/home/terdieu/gladys-dev/requeteAPI/Gladys/server/node_modules/node-webcrypto-ossl/build/Release/nodessl.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 72. This version of Node.js requires
NODE_MODULE_VERSION 83. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).
at Object.Module._extensions..node (internal/modules/cjs/loader.js:1144:18)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:12)
at Module.require (internal/modules/cjs/loader.js:974:19)
at require (internal/modules/cjs/helpers.js:101:18)
at Object.<anonymous> (/home/terdieu/gladys-dev/requeteAPI/Gladys/server/node_modules/node-webcrypto-ossl/buildjs/native.js:3:16)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:12)
at Module.require (internal/modules/cjs/loader.js:974:19)
at require (internal/modules/cjs/helpers.js:101:18)
at Object.<anonymous> (/home/terdieu/gladys-dev/requeteAPI/Gladys/server/node_modules/node-webcrypto-ossl/buildjs/key_storage.js:8:16)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Module.load (internal/modules/cjs/loader.js:950:32) {
code: 'ERR_DLOPEN_FAILED'
}
npm ERR! code ELIFECYCLE
⠙ Verifying Cypress can run /home/terdieu/.cache/Cypress/6.9.1/Cypress
npm ERR! gladys-server@ cypress:start: `cross-env SQLITE_FILE_PATH=./gladys-cypress.db node index.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the gladys-server@ cypress:start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/terdieu/.npm/_logs/2022-04-13T04_06_38_053Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! gladys-server@ cypress: `npm run cypress:clean && npm run cypress:start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the gladys-server@ cypress script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/terdieu/.npm/_logs/2022-04-13T04_06_38_092Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! gladys@4.8.3 start-server:cypress: `cd server && npm run cypress`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the gladys@4.8.3 start-server:cypress script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/terdieu/.npm/_logs/2022-04-13T04_06_38_114Z-debug.log
⠹ Verifying Cypress can run /home/terdieu/.cache/Cypress/6.9.1/Cypress
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! gladys@4.8.3 start:cypress: `run-p start-server:cypress start-front:cypress`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the gladys@4.8.3 start:cypress script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/terdieu/.npm/_logs/2022-04-13T04_06_38_161Z-debug.log
ERROR: "start:cypress" exited with 1.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! gladys@4.8.3 cypress: `run-p start:cypress cypress:open`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the gladys@4.8.3 cypress script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/terdieu/.npm/_logs/2022-04-13T04_06_38_202Z-debug.log
Sin embargo, debes ejecutar un npm rebuild si has cambiado la versión de Node (está escrito en los logs anteriores) porque los paquetes se instalaron con Node 12.