Skip to content

StevanFreeborn/OnspringEnd2EndTests

Repository files navigation

OnspringEnd2EndTests

A suite of automated web app tests for the Onspring platform using:

Getting Started

Prerequisites

  • Node.js (latest LTS version)
  • npm (latest LTS version)

Installation

👨🏻‍💻 Clone the repo

git clone https://github.com/StevanFreeborn/OnspringEnd2EndTests.git

💾 Install NPM packages

npm install

🎭 Install Playwright Dependencies

npx playwright install

📝 Create .env file

Copy the example.env file and rename it to .env

cp example.env .env

Update the .env file with values for your environment

Usage

Run all tests

npm run test

Run all tests for specific browser

npx run test:chrome

-- or --

npx run test -- --project=chrome

Run a specific suite of tests

npm run test -- app.spec.ts

Run a specific test

npm run test -- -g "Delete a user"

Run tests against specific target environment

A helpful script to run tests against a specific target environment without having to alter the .env file. Note you can pass all the same arguments as you would to npm run test to this script. But note the --target argument should come first followed by -- and then the rest of the arguments you want to pass to the test script.

npm run test:env --target=<target> -- emailBody.spec.ts --project chrome

Learn more about Playwright's Test CLI

Playwright CLI

Workflows

This workflow runs the Playwright tests in a GitHub Actions workflow and allows you to supply an environment variable for the environment you want to run the tests against. It will only run when directly triggered by a user.

This workflow runs ESLint and Prettier against the codebase to ensure code quality and consistency. It will run on any pull request that merges into the master branch.

This workflow will run on any pull request that aims to merge into the master branch. It will run all the tests found in .spec.ts files changed by the PR a total of 3 times in a row allowing for 1 retry to ensure the tests are stable. Making the allowance for 1 retry is an effort to reduce the number of false negatives due to transient timeouts.

Relevant Notes

Email Testing

Some tests require the ability to verify that an email was sent. This is currently done using IMAP and the imap package. You can read more about it here. The email account for the system administrator user running the tests can be configured in the .env file.

When it is necessary to verify an email was sent to specific user currently an alias (e.g. system.admin+<some unique identifier>@gmail.com) is used to send the email to the system administrator user. The system administrator user's email account is configured in the .env file. The alias is then used to filter the emails in the inbox to find the email sent to the specific user.

PDF Testing

Some tests require the ability to verify the contents of a PDF. This is currently done using the PDF.js package. This library is used to parse the PDF after it has been downloaded.

Excel Testing

Some tests require the ability to verify the contents of an Excel file. This is currently done using the node-xlsx package. This library is used to parse the Excel file after it has been downloaded.