- Issue created by @bnjmnm
- Issue was unassigned.
- Status changed to Needs review
4 months ago 3:51pm 1 August 2024 - Status changed to Needs work
4 months ago 1:37pm 5 August 2024 - Assigned to hooroomoo
- πΊπΈUnited States hooroomoo
hooroomoo β changed the visibility of the branch 3465241-test-instructions to hidden.
- πΊπΈUnited States hooroomoo
hooroomoo β changed the visibility of the branch 3465241-test-instructions to hidden.
- πΊπΈUnited States hooroomoo
hooroomoo β changed the visibility of the branch 3465241-test-instructions to active.
- Issue was unassigned.
- Status changed to Needs review
4 months ago 8:38pm 5 August 2024 - Assigned to wim leers
- Issue was unassigned.
- Status changed to RTBC
4 months ago 2:31pm 7 August 2024 - π§πͺBelgium wim leers Ghent π§πͺπͺπΊ
Assumptions/context
- I run & develop Drupal using a no-abstractions development environment, which anybody can get using this guide: https://getgrav.org/blog/macos-sonoma-apache-multiple-php-versions
- I have never run a Cypress test locally. I have never seen how one should run it either. I have never even read any docs on it.
Running unit/component tests
If I follow the instructions here, I get:
$ npm run cy:component > vite-template-redux@0.0.0 cy:component > cypress run --component --browser electron Cypress cannot run because this binary file does not have executable permissions here: /Users/wim.leers/Library/Caches/Cypress/13.12.0/Cypress.app/Contents/MacOS/Cypress Reasons this may happen: - node was installed as 'root' or with 'sudo' - the cypress npm package as 'root' or with 'sudo' Please check that you have the appropriate user permissions. You can also try clearing the cache with 'cypress cache clear' and reinstalling. ---------- Platform: darwin-arm64 (22.3.0) Cypress Version: 13.12.0
Which baffled me because I don't recall doing that. Apparently that file exists since June 18. But β¦ how? π€ I get the same error after
rm -rf node_modules
and thennpm install
β which makes sense, because it's outsidenode_modules
.So, how did I get that file then?
- Not
npm
, because:
$ npm list -g /Users/wim.leers/.nvm/versions/node/v18.16.1/lib βββ @mermaid-js/mermaid-cli@10.9.1 βββ corepack@0.28.1 βββ cspell@8.10.4 βββ glob-run@0.1.7 βββ npm@9.5.1
- Not
brew
, because:
$ brew list | grep cypress
π€π
So I did
npm install cypress
notnpm install
, which resulted in:changed 1 package, and audited 1010 packages in 43s
Huh?! π€ͺ
This did not modify that file:
ls -al /Users/wim.leers/Library/Caches/Cypress/13.12.0/Cypress.app/Contents/MacOS/Cypress -rw-------@ 1 wim.leers staff 69536 Jun 18 19:23 /Users/wim.leers/Library/Caches/Cypress/13.12.0/Cypress.app/Contents/MacOS/Cypress
(Still June 18!)
BUT, now I get:
$ npm run cy:component > vite-template-redux@0.0.0 cy:component > cypress run --component --browser electron It looks like this is your first time using Cypress: 13.13.2 β Verified Cypress! /Users/wim.leers/Library/Caches/Cypress/13.13.2/Cypress.app Opening Cypress... DevTools listening on ws://127.0.0.1:51313/devtools/browser/4847d411-cc4b-4a4b-8816-cedd82d516f1 (node:6511) ExperimentalWarning: Custom ESM Loaders is an experimental feature and might change at any time (Use `node --trace-warnings ...` to show where the warning was created) (node:6511) ExperimentalWarning: The Node.js specifier resolution flag is experimental. It could change or be removed at any time. The CJS build of Vite's Node API is deprecated. See https://vitejs.dev/guide/troubleshooting.html#vite-cjs-node-api-deprecated for more details. ==================================================================================================== (Run Starting) ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β Cypress: 13.13.2 β β Browser: Electron 118 (headless) β β Node Version: v18.16.1 (/Users/wim.leers/.nvm/versions/node/v18.16.1/bin/node) β β Specs: 3 found (configurationSlice.cy.js, layoutslice.cy.js, uiSlice.cy.js) β β Searched: ../tests/src/Cypress/cypress/component/**/*.cy.{js,ts,jsx,tsx}, ../tests/src/C β β ypress/cypress/unit/**/*.cy.{js,ts,jsx,tsx} β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ <<<SNIP>>> (Run Finished) Spec Tests Passing Failing Pending Skipped ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β β configurationSlice.cy.js 33ms 1 1 - - - β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€ β β layoutslice.cy.js 103ms 6 6 - - - β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€ β β uiSlice.cy.js 45ms 4 4 - - - β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β All specs passed! 181ms 11 11 - - -
π€·ββοΈ
This makes no sense. But I got it working. And it feels like
npm
weirdness? π€ Anyway, captured here for posterity in case somebody else runs into it!Running E2E tests
- Created the
.env
file per the instructions:
BASE_URL='http://core.test' DB_URL='mysql://root:root@localhost/core' # VITE_SERVER_ORIGIN='http://localhost:5173'
- Executed
, and discovered that keeps sending output to the terminal. So β¦ I suggest recommending that this is done in a <em>separate</em> terminal. That app launches β can't wait to see my E2E tests running in there π€ <li>Executed <code>npm run cy:run
β¦ and it passed:
<<<SNIP>>> ==================================================================================================== (Run Finished) Spec Tests Passing Failing Pending Skipped ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β β a11y.cy.js 00:19 4 4 - - - β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€ β β canary.cy.js 00:17 2 2 - - - β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€ β β xb-general.cy.js 00:20 4 4 - - - β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β All specs passed! 00:58 10 10 - - -
- β οΈ But it did not show anything in the Cypress app/UI! π¬ So what's going on here?
- I did see that there was a "What's new"-esque splash screen. Maybe that was blocking it? I clicked through it. Did
npm run cy:run
again. Still nothing. π¬ - So β¦ okay, I click "E2E" testing: . I then have to choose a browser. I pick Chrome. (I thought it was going to use that automatically?! π€·ββοΈ) Then I can click β¦ so I click that.
- Now I see: π€
- WTH is this? I thought this was just going to show the tests I was running through
npm run cy:run
?!- What happens if I click
xb-general.cy.js
? π€- Victory:
- What happens if I click
Conclusion
Despite all that β¦ it took me <20 minutes to get it all up and running and write this comment (which is ~50% of the time).
This just needs a clarification IMHO: one should choose between either
npm run cy:open
ornpm run cy:run
. Suggestion: https://git.drupalcode.org/project/experience_builder/-/merge_requests/1...That would probably be obvious to anybody familiar with Cypress, but not to anybody new to it, like me π
- Assigned to bnjmnm
- π§πͺBelgium wim leers Ghent π§πͺπͺπΊ
@bnjmnm should merge this to confirm/incorporate or reject/clarify my suggestion π
- Assigned to hooroomoo
- π§πͺBelgium wim leers Ghent π§πͺπͺπΊ
Cool!
Now this just needs @hooroomoo's sign-off π
-
hooroomoo β
committed ca9f2936 on 0.x authored by
bnjmnm β
Issue #3465241 by bnjmnm, hooroomoo, Wim Leers: Add Cypress test runner...
-
hooroomoo β
committed ca9f2936 on 0.x authored by
bnjmnm β
- Issue was unassigned.
- Status changed to Fixed
4 months ago 1:35pm 8 August 2024 Automatically closed - issue fixed for 2 weeks with no activity.