Skip to content

Commit db4b8e3

Browse files
author
DavertMik
committed
fixed flaky tests
1 parent 4c90c15 commit db4b8e3

File tree

3 files changed

+10
-16
lines changed

3 files changed

+10
-16
lines changed

.github/workflows/playwright.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ jobs:
4646
timeout-minutes: 2
4747
- name: start a server
4848
run: 'php -S 127.0.0.1:8000 -t test/data/app &'
49+
- name: start json-server
50+
run: 'npm run json-server &'
51+
- name: wait for servers
52+
run: 'sleep 3'
4953
- name: run chromium unit tests
5054
run: ./node_modules/.bin/mocha test/helper/Playwright_test.js --timeout 5000 --reporter @testomatio/reporter/mocha
5155
timeout-minutes: 18

test/acceptance/config_test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Scenario('change config 5 @WebDriverIO @Puppeteer @Playwright', ({ I }) => {
3232

3333
Scenario('make API call and check response @Playwright', ({ I }) => {
3434
I.amOnPage('/')
35-
I.makeApiRequest('get', 'https://reqres.in/api/users?page=2', { headers: {'x-api-key': 'reqres-free-v1'}})
35+
I.makeApiRequest('get', 'http://127.0.0.1:8010/posts/1')
3636
I.seeResponseCodeIsSuccessful()
3737
})
3838

test/helper/Playwright_test.js

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -133,17 +133,6 @@ describe('Playwright', function () {
133133
})
134134
})
135135

136-
describe('#seeCssPropertiesOnElements', () => {
137-
it('should check background-color css property for given element', async () => {
138-
try {
139-
await I.amOnPage('https://codecept.io/helpers/Playwright/')
140-
await I.seeCssPropertiesOnElements('.navbar', { 'background-color': 'rgb(128, 90, 213)' })
141-
} catch (e) {
142-
e.message.should.include("expected element (.navbar) to have CSS property { 'background-color': 'rgb(128, 90, 213)' }")
143-
}
144-
})
145-
})
146-
147136
webApiTests.tests()
148137

149138
describe('#click', () => {
@@ -1001,9 +990,10 @@ describe('Playwright', function () {
1001990

1002991
describe('#makeApiRequest', () => {
1003992
it('should make 3rd party API request', async () => {
1004-
const response = await I.makeApiRequest('get', 'https://reqres.in/api/users?page=2')
993+
// Using local json-server for reliable testing
994+
const response = await I.makeApiRequest('get', 'http://127.0.0.1:8010/posts/1')
1005995
expect(response.status()).to.equal(200)
1006-
expect(await response.json()).to.include.keys(['page'])
996+
expect(await response.json()).to.include.keys(['id', 'title', 'author'])
1007997
})
1008998

1009999
it('should make local API request', async () => {
@@ -1014,10 +1004,10 @@ describe('Playwright', function () {
10141004
it('should convert to axios response with onResponse hook', async () => {
10151005
let response
10161006
I.config.onResponse = resp => (response = resp)
1017-
await I.makeApiRequest('get', 'https://reqres.in/api/users?page=2')
1007+
await I.makeApiRequest('get', 'http://127.0.0.1:8010/posts/1')
10181008
expect(response).to.be.ok
10191009
expect(response.status).to.equal(200)
1020-
expect(response.data).to.include.keys(['page', 'total'])
1010+
expect(response.data).to.include.keys(['id', 'title', 'author'])
10211011
})
10221012
})
10231013

0 commit comments

Comments
 (0)