I tested the Cypress branch you developed today and it works well
I started testing the front end of the Tp-Link service and I’m making good progress. The fixture/mock part of the backend calls is a bit more complex but it works too.
I think we really need to switch to TDD mode to write this kind of tests.
For the backend API part, do we want to test only the core? The rest (services) is too tied to the hardware so we want to mock everything, right?
I think there is a mistake between the doc and the command in the package.json to start the server for the Cypress tests (npm run start:cypress <= npm run cypress:start)
Thanks for the work and looking forward to seeing it in the CI and in the coverage
Yes, it will be simpler to set up our tests and also to validate our developments.
It would be good to test the core as much as possible. However, for interactions with devices, it’s complicated, so we need to try to mock only the WebServices calling the real services.
If we do it on a config page (like for Bluetooth and the scan frequency, which only records parameters in the database).
The npm run cypress:start script should not be in the root package.json file, and the documentation specifies that you need to be at the root of Gladys (neither on front nor on server).
(yes I know cypress:start vs start:cypress, I tried to follow the « logic » already in place, but everything is changeable ).
With my PR, the CI already runs the tests (blocking in case of error), only the coverage is missing.
Thanks for trying, with @pierre-gilles we agreed that I should test the « react-select » component which is a bit particular (in order to provide the technique to apply), and let the community play with it before merging, then merge little by little, to avoid the tunnel effect (and I admit that working 5 days in a row on it, it’s tiring).
@AlexTrovato So do you think I can merge the Cypress PR soon? I think, as we discussed, we can merge it even if not everything is covered, that way at least the structure is on master and we can base further PRs on it to add coverage
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) building
Browserslist: 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) building
Browserslist: 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
And finally tried to launch Cypress (attempt from the front and the root of 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
I then tried to follow the link you provide in your slides:
Well, it’s done, so it adds things, at least it really tries to launch ^^
But it crashes ^^ - I’ll check that this evening when I get home ^^:
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
However, you need to run npm rebuild if you changed the Node.js version (it’s written in the previous logs) because the packages were installed under Node 12.