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

Initial version of a e2e test suite created with Cypress and Cucumber #145

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Holger-Mayer
Copy link
Contributor

Introduce Cypress test framework for e2e testing

Overview

The Protractor test package reached end-of-life in August 2023. A new end to end testing solution is necessary. Cypress is a modern Javascript based testing solution for e2e and component tests. This pull request implements an initial installation of a Cypress test suite. Currently, we only test basic front-end functions. These tests and the test infrastructure code behind these lay the base for further test suite enhancements.
The implemented test framework adds a Cucumber interface to Cypress, allowing tests to be described in Gherkin and executed using Javascript glue code.

Installation

The following have been installed and are now included in the package.json.

You need these for Cypress with Cucumber.
npm install --save-dev [email protected] -
npm install --save-dev @badeball/cypress-cucumber-preprocessor
npm install --save-dev @bahmutov/cypress-esbuild-preprocessor
npm install --save-dev ts-loader

We need concurrently and wait-on for starting the angular application and wait for the start of the testing until the website is ready

npm install --save-dev concurrently
npm install --save-dev wait-on

We need rimraf because when switching between Cypress App and headless testing, Cypress gets problems with the .angular/cache. rimraf is used to delete the cache before starting a headless test.

npm install rimraf --save-dev

Configuration Changes

The file e2e/cypress/fixtures/config.json is loaded by the test suite for the base URLs of the rest server app and the Angular front end app. If these are not the standard values, these need to be changed.

cypress.config.ts

Defines core parameter for cypress, especially the paths to test and result files.

tsconfig.json

This change is necessary for using Cypress with the Cucumber preprocessor.

    "paths": {
        "@badeball/cypress-cucumber-preprocessor/*": ["./node_modules/@badeball/cypress-cucumber-preprocessor/dist/bundler-utils/*"]
      }

package.json

Package.json changed for

  • new scripts
  • additional devDependencies

README .md

The e2e test paragraph underwent changes.

A test suite documentation README.md is available under e2e/cypress/docs/README.md.

.gitignore

I changed the Git ignore to prevent storing the result files of a test run in git.

First simple frontend tests - form validation

I implemented form validation tests and CRUD-Tests for pet owner. Once this pull request is accepted, we can and should implement additional tests.

Future steps

  • CRUD-Tests for all objects
  • Workflow tests

Current Bug in Angular Application

Currently, there is a bug in the veterinarian edit function of the angular application.
While the html source code specifies a minimum length for the veterinarian’s first name, the application does not. It needs at least 2 characters for a valid first name.

Github Actions

The test suite is not integrated into the Github actions script!

This should be done at a late evolution step of the suite instead of right now possibly creating havoc.

@@ -164,9 +164,19 @@ Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.

## Running end-to-end tests

### Protractor (deprecated)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I propose to remove Protactor and keep the e2e goal that is common.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are conflicts

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could use some help here. Which parts are in conflict?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't know:

17,302 additions, 10,810 deletions not shown because the diff is too large. Please use a local Git client to view these changes.

You may use this resolution method: https://medium.com/@hugodzin/resolving-git-conflicts-in-package-lock-json-25c0d52bc2f or this another one: https://gist.github.com/szemate/6fb69c8e3d8cce3efa9a6c922b337d98

And I see the owner details with first name "Travis" last name "Peterson" address "North Park Blvd" city "Bielefeld" telephone "49492020"

###Information:
### Scenario: Delete owner
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could create an issue to add this feature.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feature could be added to the issue list and implemented later. I recommend that we first get the UI e2e tests up an running. I also think it would be better to add API tests before changing or adding functionality.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I am agree. Creating the issue will allow us to have this evolution in our backlog

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't know:

17,302 additions, 10,810 deletions not shown because the diff is too large. Please use a local Git client to view these changes.

You may use this resolution method: https://medium.com/@hugodzin/resolving-git-conflicts-in-package-lock-json-25c0d52bc2f or this another one: https://gist.github.com/szemate/6fb69c8e3d8cce3efa9a6c922b337d98

And I see the owner details with first name "Travis" last name "Peterson" address "North Park Blvd" city "Bielefeld" telephone "49492020"

###Information:
### Scenario: Delete owner
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I am agree. Creating the issue will allow us to have this evolution in our backlog

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.

2 participants