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

Create CI to run e2e automated tests #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .github/e2e-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: End-to-end

on:
pull_request:

jobs:
e2e_tests:
name: End-to-end tests run
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Use specific node version
uses: actions/setup-node@v3
with:
node-version: '16.x'
cache: 'yarn'

- name: Install dependencies
run: yarn install
shell: bash

- name: Run end-to-end tests
run: yarn run test:e2e

- name: Generate end-to-end tests report
run: yarn run test:generate:report
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
},
"scripts": {
"test:e2e": "wdio run ./wdio.conf.js --spec ./test/specs/*.e2e.js",
"test:generate:report": "marge ./test/results/wdio-ma-merged.json --reportTitle 'End-to-end tests report' --reportDir ./test/results --reportFilename 'e2e-report'"
"test:generate:report": "marge ./test/results/results-0-0.json --reportTitle 'End-to-end tests report' --reportDir ./test/results --reportFilename 'e2e-report'"
}
}
15 changes: 15 additions & 0 deletions test/pages/login.page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
class LoginPage {

get username () { return $('#email') }
get password () { return $('#password') }
get enterBtn () { return $('button=Entrar') }

async fillSubmitForm (user, pass) {
await this.username.setValue(user)
await this.password.setValue(pass)
await this.enterBtn.click()
}

}

export default new LoginPage()
14 changes: 0 additions & 14 deletions test/specs/example.e2e.js

This file was deleted.

25 changes: 16 additions & 9 deletions test/specs/login.e2e.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
describe('My Login application', () => {
it('should login with valid credentials', async () => {
await browser.url(`https://the-internet.herokuapp.com/login`)
import LoginPage from '../pages/login.page.js'

await $('#username').setValue('tomsmith')
await $('#password').setValue('SuperSecretPassword!')
await $('button[type="submit"]').click()
describe('Application login', () => {
it('signs in with valid credentials', async () => {
await browser.url('/')

await expect($('#flash')).toBeExisting()
await expect($('#flash')).toHaveTextContaining(
'You logged into a secure area!')
await LoginPage.fillSubmitForm('[email protected]', 'generic')

await expect(browser).toHaveUrlContaining('home')
await expect($('h1')).toHaveTextContaining('Serverest Store')
})

it('shows error message with wrong password', async () => {
await browser.url('/')

await LoginPage.fillSubmitForm('[email protected]', 'wrong')

await expect($('.alert')).toHaveTextContaining('Email e/ou senha inválidos')
})
})