cypress-sharepoint-sample icon indicating copy to clipboard operation
cypress-sharepoint-sample copied to clipboard

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

Open swiftinitdotcom opened this issue 3 years ago • 16 comments

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

swiftinitdotcom avatar Sep 08 '22 05:09 swiftinitdotcom

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.

estruyf avatar Sep 08 '22 06:09 estruyf

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

swiftinitdotcom avatar Sep 08 '22 07:09 swiftinitdotcom

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

estruyf avatar Sep 08 '22 07:09 estruyf

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

sinnitesh avatar Jun 02 '23 01:06 sinnitesh

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

necik11 avatar Aug 23 '23 07:08 necik11

@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.

estruyf avatar Aug 23 '23 08:08 estruyf

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.

necik11 avatar Aug 23 '23 08:08 necik11

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

estruyf avatar Aug 24 '23 13:08 estruyf

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?

necik11 avatar Aug 24 '23 14:08 necik11

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

estruyf avatar Aug 24 '23 14:08 estruyf

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.

necik11 avatar Aug 24 '23 14:08 necik11

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

estruyf avatar Aug 24 '23 14:08 estruyf

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

necik11 avatar Aug 24 '23 14:08 necik11

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?

necik11 avatar Jul 23 '24 08:07 necik11

@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 avatar Jul 23 '24 08:07 estruyf

@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

estruyf avatar Jul 24 '24 08:07 estruyf