estruyf / cypress-sharepoint-sample

Cypress E2E testing for SharePoint solutions sample
MIT License
21 stars 17 forks source link

is this updated and is it going to work end to end in sharepoint online based js pages? #5

Open swiftinitdotcom opened 2 years ago

swiftinitdotcom commented 2 years ago

Hi we want to do automated testing for sharepoint online based workflow forms is it possible to do it using cypress the html forms are mostly javascript based html forms and 20 workflows similar forms 4 stage workflows currently doing manual testing

estruyf commented 2 years ago

This sample is already two years old. I cannot say if it will still work, but I believe it should. Just give it a try.

swiftinitdotcom commented 2 years ago

thanks, is there anything better than this for sharepoint online automated testing?

estruyf commented 2 years ago

I wouldn't say better, it's just a preference. I like Cypress, but you can also check Playwright, Selenium, ...

sinnitesh commented 1 year ago

This sample is already two years old. I cannot say if it will still work, but I believe it should. Just give it a try.

I am struggling with this sample and seems not working

necik11 commented 1 year ago

Yes i am struggling with this sample and all others :), my biggest achievement was when i logged successfully into microsoft.login but anyway after call cy.visit("sharepoint") its nothing happen just a after long time load failed .. I already ask in anothers topics but noone probably use cypress nowdays for sharepoint online...

https://github.com/cypress-io/cypress/discussions/27615

https://github.com/SharePoint/sp-dev-docs/issues/9128

estruyf commented 1 year ago

@necik11 @sinnitesh I've recently switched to Playwright because its testing tools got a lot better and they introduced a test UI similar to what Cypress offers.

I'll write and share an example of it in the coming weeks.

The biggest advantage of using Playwright is that it doesn't have the iframe issues from Cypress.

necik11 commented 1 year ago

Thank you for a tip Playwright and if there come some samples it will be great. I have some SPFx components / extensions and i wanted make some trivials tests for my CI / CD. I have feeling e2e tests could be better for testing after deploy on develop tenant. But with Cypress seems more problems come(iframe, some experimental configs) then some income.

estruyf commented 1 year ago

Just uploaded my Playwright template: https://github.com/estruyf/testing-microsoft365-playwright-template

necik11 commented 1 year ago

I am not sure if i am doing something wrong but firstly i got error: "NODE_ENV" is not recognized as an internal or external command, operable command or batch file npm install -g win-node-env this work well but after npm test i have got error: image

with npm run test:ui i have got same error.

After rename .env.sample -> .env npm test -> still not working but difference with npm run test:ui : i am stucked at this: image

Could be a problem npm test cache wrong environments? And second problem can only think of with Cypress sometimes show i am logged with my "windows authentication" can not be the same problem?

estruyf commented 1 year ago

@necik11 did you create the .env file with the PAGE_URL, USERNAME, and PASSWORD variables?

necik11 commented 1 year ago

Yes of course - it was 1st stuff what am i did: "To get started, you need to configure the following environment variables" so i fill values: .env.sample but what I wrote is what followed.

estruyf commented 1 year ago

Did some updates to the environment variables, it should now work on Windows as well.

necik11 commented 1 year ago

It works great Thank you! You just need to rename the configuration file .env.sample -> .env

necik11 commented 1 month ago

Hello, is there a solution that could also be used for production deployment? Since there is two-phase verification on the production servers... So via a simple post E.g. via appId + clientServer/ cert? Do you include the graph library? Or at least login in Windows credentials, which would be saved for some time, and take this session? Or is this unrealistic and is only suitable for testing environments?

estruyf commented 1 month ago

@necik11 It becomes tricky if there is 2FA involved. E2E tests should be run on QA/Test environments. That said, a couple of months ago, I spoke to somebody who told me there could be a way, but it would mean you generate an access token and use it in your CI/CD until it expires.

Another approach could be to log in locally with Playwright (not running in headless mode), let it create the auth file, and use that in your CI/CD as a secret.

estruyf commented 1 month ago

@necik11 I just updated the Playwright template to support MFA as well. Here you can see the automated login flow:

https://github.com/user-attachments/assets/def67313-deaf-4de6-a784-20c311c44e19

Template: https://github.com/estruyf/testing-microsoft365-playwright-template