Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use cypress for integration tests #6646

Merged
merged 1 commit into from Feb 4, 2020
Merged

Use cypress for integration tests #6646

merged 1 commit into from Feb 4, 2020

Conversation

Fryguy
Copy link
Member

@Fryguy Fryguy commented Jan 31, 2020

cc @himdel @chessbyte

This PR is a basic POC of writing integration tests with cypress.

I chose cypress because I like how it doesn't use selenium/phantomjs, but instead spins up a real headless browser and interacts with it directly. The tooling for it is really good with a live interactive UI with time travel and DOM selector discovery, CLI support, screenshot generation on failure, video generation of the run, and a lot more. It only supports Chrome (and Chromium/Canary/Electron) right now, but they are very close to getting Firefox. Even so, for 1st tier testing Chrome should be more than good enough.

Running the tests

In a separate tab, run bundle exec rails server, then...

$ npm run cypress:run

> manageiq-ui-classic@1.0.0 cypress:run /Users/jfrey/dev/manageiq-ui-classic
> cypress run --headless --browser chrome


====================================================================================================

  (Run Starting)

  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ Cypress:    3.8.3                                                                              │
  │ Browser:    Chrome 79 (headless)                                                               │
  │ Specs:      1 found (ui/login.spec.js)                                                         │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘


────────────────────────────────────────────────────────────────────────────────────────────────────

  Running:  ui/login.spec.js                                                                (1 of 1)


  Login
    ✓ login page (27337ms)


  1 passing (27s)


  (Results)

  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ Tests:        1                                                                                │
  │ Passing:      1                                                                                │
  │ Failing:      0                                                                                │
  │ Pending:      0                                                                                │
  │ Skipped:      0                                                                                │
  │ Screenshots:  0                                                                                │
  │ Video:        true                                                                             │
  │ Duration:     27 seconds                                                                       │
  │ Spec Ran:     ui/login.spec.js                                                                 │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘


  (Video)

  -  Started processing:  Compressing to 32 CRF
  -  Finished processing: /Users/jfrey/dev/manageiq-ui-classic/cypress/videos/ui/logi     (1 second)
                          n.spec.js.mp4


====================================================================================================

  (Run Finished)


       Spec                                              Tests  Passing  Failing  Pending  Skipped
  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ ✔  ui/login.spec.js                         00:27        1        1        -        -        - │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘
  1 Initial commit for using cypress for integration tests
    ✔  All specs passed!                        00:27        1        1        -        -        -

login spec js

Running the interactive tool

  • npm run cypress:open
  • Then browse to manageiq-ui-classic
  • You can then "Run all tests", or run specfic ones.

@miq-bot
Copy link
Member

miq-bot commented Jan 31, 2020

Checked commit Fryguy@61a41bb with ruby 2.5.5, rubocop 0.69.0, haml-lint 0.20.0, and yamllint 1.10.0
0 files checked, 0 offenses detected
Everything looks fine. 👍

@himdel
Copy link
Contributor

himdel commented Feb 1, 2020

Heheh, so, I haven't figured out the custom matchers/helpers/whatever yet, but for traversing the menu, this works...

https://www.himdel.eu/menu.spec.js.mp4
https://gist.github.com/himdel/c5e0bfb94201d0525f462656139a5c88

@Fryguy
Copy link
Member Author

Fryguy commented Feb 1, 2020

I knew you'd give it a shot 😉

Their website has really good docs and a tutorial with best practices, so will probably be a good resource for things like the custom matchers

@Fryguy Fryguy changed the title [WIP] [POC] Use cypress for integration tests Use cypress for integration tests Feb 3, 2020
@Fryguy Fryguy removed the wip label Feb 3, 2020
@Fryguy
Copy link
Member Author

Fryguy commented Feb 3, 2020

@himdel As discussed, I've unWIPed and I'll make a follow up PR with making it run through Travis.

@himdel himdel added this to the Sprint 130 Ending Feb 17, 2020 milestone Feb 4, 2020
@himdel himdel merged commit c5c4559 into ManageIQ:master Feb 4, 2020
@Fryguy Fryguy deleted the cypress branch February 4, 2020 15:25
@himdel himdel mentioned this pull request Feb 6, 2020
@himdel himdel added the cypress label Feb 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants