Skip to content

Commit

Permalink
NOTICKET: Improve end to end tests using retries for a more reliable …
Browse files Browse the repository at this point in the history
…run in ci pipelines and ensuring labels exists before extracting attributes (#98)
  • Loading branch information
abaeza-wp authored Jan 23, 2024
1 parent feedde1 commit bedec09
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions demo-app/e2e/config.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"setupFilesAfterEnv": ["<rootDir>/e2e/jest.setup.js"],
"globalSetup": "detox/runners/jest/globalSetup",
"globalTeardown": "detox/runners/jest/globalTeardown",
"maxWorkers": 1,
Expand Down
8 changes: 8 additions & 0 deletions demo-app/e2e/jest.setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Attempt to re-run individual tests when they fail
const retries = 5;
console.log('==========================');
console.log(
`Running Jest with retries: will retry failing tests ${retries} time(s).`
);
console.log('==========================');
jest.retryTimes(retries);
4 changes: 4 additions & 0 deletions demo-app/e2e/page-objects/LabelPO.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
/* eslint-disable @typescript-eslint/no-var-requires */
const { UIComponentPO } = require('./UIComponentPO');
const { waitFor } = require('detox');
const { TIMEOUT_IN_MS } = require('./Options');

/* eslint-enable @typescript-eslint/no-var-requires */

class LabelPO extends UIComponentPO {
async text() {
await waitFor(this.component()).toExist().withTimeout(TIMEOUT_IN_MS);
const attributes = await this.getAttributes();
return attributes.text;
}
Expand Down

0 comments on commit bedec09

Please sign in to comment.