-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Migrate existing Cypress tests to Cypress + Cucumber #57299
Conversation
Pinging @elastic/apm-ui (Team:apm) |
@@ -94,7 +94,7 @@ pipeline { | |||
dir("${BASE_DIR}"){ | |||
sh ''' | |||
jobs -l | |||
docker build --tag cypress ${CYPRESS_DIR}/ci | |||
docker build --tag cypress --build-arg NODE_VERSION=$(cat .node-version) ${CYPRESS_DIR}/ci |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we capture project's Node version from root directory
# Prepare and run Kibana locally | ||
$ x-pack/legacy/plugins/apm/e2e/ci/prepare-kibana.sh | ||
# Build Docker image for Kibana | ||
$ docker build --tag cypress --build-arg NODE_VERSION=$(cat .node-version) x-pack/legacy/plugins/apm/e2e/ci | ||
# Run Docker image | ||
$ docker run --rm -t --user "$(id -u):$(id -g)" \ | ||
-v `pwd`:/app --network="host" \ | ||
--name cypress cypress |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
Background: | ||
Given a user browses the APM UI application | ||
When the user inspects the opbeans-go service |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MadameSheema how do you see having a When
clause in a Background
? I'm not completely sure if moving this line to the Scenario itself would be a more accurate approach. wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi!! Sorry for my late reply, I was a little bit busy. I don't like to use Backgrounds at all. This is because if you have a big file in a feature you can skip it when reading it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A part from what I said in the previous comment. If you only have one scenario, it does not make sense to have a background at all :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was preparing for future updates... but I agree with you :) I'll send a commit moving the background step to the scenario. Thanks!!!
@@ -5,17 +5,20 @@ | |||
"license": "MIT", | |||
"scripts": { | |||
"cypress:open": "cypress open", | |||
"cypress:run": "cypress run" | |||
"cypress:run": "cypress run --spec **/*.feature" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are keeping the build scripts using the installed Cypress
After #57882 is merged, we can continue with this one, as the cypress+cucumber tests will not be type checked by upstream build. |
361ddef
to
29b45ac
Compare
It seems not relevant to the main purpose of these tests
We are keeping cypress as rootDir to follow project's structure. On the other hand, having a second cypress directory at the 2nd level is the default structure, as shown in the examples: - https://github.com/TheBrainFamily/cypress-cucumber-webpack-typescript-example - https://github.com/cypress-io/cypress-example-recipes/tree/a240054d7f5626ffcd7bd668dded96d219c4a7eb/examples/preprocessors__typescript-webpack
It was automatically changed by tests
We are keeping the build system within the test application, isolating dependencies
29b45ac
to
18ec45d
Compare
Hey @elastic/kibana-operations, is there anything we missed on our side here? Thanks! |
@elasticmachine merge upstream |
This would avoid not reading the background when the number of scenarios grows
💚 Build SucceededHistory
To update your PR or re-run it, just comment with: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ops files LGTM
* chore: move gitignore to the cypress directory * chore: ignore more test files * fix: do not check the Loading Message It seems not relevant to the main purpose of these tests * chore: use cypres + webpack + cucumber scaffolding See https://github.com/TheBrainFamily/cypress-cucumber-webpack-typescript-example * chore: add eslint and prettier for code linting * feat: convert existing Cypress test into BDD style * feat: add support for using proper Node version in MacOSX * chore: use tslint * chore: use old layout We are keeping cypress as rootDir to follow project's structure. On the other hand, having a second cypress directory at the 2nd level is the default structure, as shown in the examples: - https://github.com/TheBrainFamily/cypress-cucumber-webpack-typescript-example - https://github.com/cypress-io/cypress-example-recipes/tree/a240054d7f5626ffcd7bd668dded96d219c4a7eb/examples/preprocessors__typescript-webpack * chore: remove prelint script meanwhile we fix TS lint * chore: move test results to a specific directory * chore: rename variable following old code * chore: remove non-needed lints, as we are going to use kibana build * chore: import snapshot function from cypress * chore: add readFile utils back from a bad removal * chore: change format of JSON spec file It was automatically changed by tests * chore: move CI directory to the proper layout in order for Jenkins to work * chore: store test-results from proper dir on Jenkins * chore: store artifacts properly on Jenkins * Fix type issues * chore: rename test application to e2e (end-to-end) We are keeping the build system within the test application, isolating dependencies * docs: reorganise docs for APM UI e2e tests * fix: Use proper cypress support file * chore: use existing NPM script for running cypress on CI * chore: update paths in CI scripts * docs: document how the CI runs the tests * chore: use Node 10 for tests * chore: Use kibana's Node version for tests * chore: run yarn install * docs: update docs * fix: path was wrong * docs: fix paths and flags used to load data * docs: elasticsearch fix flag * docs: Bootstrap kibana before running it * docs: remove outdated info * chore: move background steps to the scenario This would avoid not reading the background when the number of scenarios grows Co-authored-by: Dario Gieselaar <[email protected]> Co-authored-by: Elastic Machine <[email protected]>
* chore: move gitignore to the cypress directory * chore: ignore more test files * fix: do not check the Loading Message It seems not relevant to the main purpose of these tests * chore: use cypres + webpack + cucumber scaffolding See https://github.com/TheBrainFamily/cypress-cucumber-webpack-typescript-example * chore: add eslint and prettier for code linting * feat: convert existing Cypress test into BDD style * feat: add support for using proper Node version in MacOSX * chore: use tslint * chore: use old layout We are keeping cypress as rootDir to follow project's structure. On the other hand, having a second cypress directory at the 2nd level is the default structure, as shown in the examples: - https://github.com/TheBrainFamily/cypress-cucumber-webpack-typescript-example - https://github.com/cypress-io/cypress-example-recipes/tree/a240054d7f5626ffcd7bd668dded96d219c4a7eb/examples/preprocessors__typescript-webpack * chore: remove prelint script meanwhile we fix TS lint * chore: move test results to a specific directory * chore: rename variable following old code * chore: remove non-needed lints, as we are going to use kibana build * chore: import snapshot function from cypress * chore: add readFile utils back from a bad removal * chore: change format of JSON spec file It was automatically changed by tests * chore: move CI directory to the proper layout in order for Jenkins to work * chore: store test-results from proper dir on Jenkins * chore: store artifacts properly on Jenkins * Fix type issues * chore: rename test application to e2e (end-to-end) We are keeping the build system within the test application, isolating dependencies * docs: reorganise docs for APM UI e2e tests * fix: Use proper cypress support file * chore: use existing NPM script for running cypress on CI * chore: update paths in CI scripts * docs: document how the CI runs the tests * chore: use Node 10 for tests * chore: Use kibana's Node version for tests * chore: run yarn install * docs: update docs * fix: path was wrong * docs: fix paths and flags used to load data * docs: elasticsearch fix flag * docs: Bootstrap kibana before running it * docs: remove outdated info * chore: move background steps to the scenario This would avoid not reading the background when the number of scenarios grows Co-authored-by: Dario Gieselaar <[email protected]> Co-authored-by: Elastic Machine <[email protected]> Co-authored-by: Manuel de la Peña <[email protected]> Co-authored-by: Dario Gieselaar <[email protected]> Co-authored-by: Elastic Machine <[email protected]>
Summary
It converts the existing Cypress tests for APM from Cypress to Cypress+Cucumber. To achieve that, it adds a cucumber-preprocessor, as shown in the following examples:
The cypress tests are run using the same npm run cypress:run script, so no CI command should be affected.
To follow a proper Cypress layout, we enclosed the end-to-end (e2e) tests under the
x-pack/legacy/plugins/apm/e2e
directory, where its own package.json will be located, controlling the life cycle if these tests. Then, acypress
directory will contain the implementation of the e2e tests.We've kept the buid dependencies under apm/e2e because we consider having the testime dependencies isolated from other plugins is important for the sake of running the test during local developement with a nice experience.
Checklist
- [ ] Any text added follows EUI's writing guidelines, uses sentence case text and includes i18n support- [ ] This was checked for keyboard-only and screenreader accessibility- [ ] This renders correctly on smaller devices using a responsive layout. (You can test this in your browser- [ ] This was checked for cross-browser compatibility, including a check against IE11For maintainers
- [ ] This was checked for breaking API changes and was labeled appropriatelySteps to run the tests
Please follow instructions in the README of the APM UI tests:
$ git clone https://github.com/elastic/apm-integration-testing.git $ cd apm-integration-testing $ ./scripts/compose.py start master --no-kibana --no-xpack-secure
$ cd x-pack/legacy/plugins/apm/e2e/cypress/ingest-data $ curl https://storage.googleapis.com/apm-ui-e2e-static-data/events.json --output events.json
$ cd x-pack/legacy/plugins/apm/e2e/cypress/ingest-data $ node replay.js --server-url http://localhost:8200 --secret-token abcd --events ./events.json
Screenshots
Feature file
Tests passing locally in headless mode (
npm run cypress:run
):Tests passing locally using Cypress app (
npm run cypress:open
):Related Issues