All Projects → bZichett → jest-retry

bZichett / jest-retry

Licence: other
Jest retry pattern for flaky E2E tests

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to jest-retry

Testcafe
A Node.js tool to automate end-to-end web testing.
Stars: ✭ 9,176 (+25388.89%)
Mutual labels:  test, test-automation, e2e
Cypress
Fast, easy and reliable testing for anything that runs in a browser.
Stars: ✭ 35,145 (+97525%)
Mutual labels:  test, test-automation, e2e-tests
Javascript Testing Best Practices
📗🌐 🚢 Comprehensive and exhaustive JavaScript & Node.js testing best practices (August 2021)
Stars: ✭ 13,976 (+38722.22%)
Mutual labels:  test, e2e-tests, e2e
Cypress Svelte Unit Test
Unit testing Svelte components in Cypress E2E test runner
Stars: ✭ 110 (+205.56%)
Mutual labels:  test, e2e
Tib
Easy e2e browser testing in Node
Stars: ✭ 64 (+77.78%)
Mutual labels:  test, e2e
Test Each
🤖 Repeat tests. Repeat tests. Repeat tests.
Stars: ✭ 89 (+147.22%)
Mutual labels:  test, test-automation
Cli Prompts Test
Write e2e tests for CLI apps with ease
Stars: ✭ 17 (-52.78%)
Mutual labels:  test, e2e-tests
Hitchhiker
a Restful Api test tool
Stars: ✭ 2,175 (+5941.67%)
Mutual labels:  test, test-automation
Ztest
自动化测试报告
Stars: ✭ 143 (+297.22%)
Mutual labels:  test, test-automation
saloon
An E2E test seeder for enterprise web applications
Stars: ✭ 30 (-16.67%)
Mutual labels:  test-automation, e2e-tests
playwright-ci
☁️ Set up Playwright in CI
Stars: ✭ 27 (-25%)
Mutual labels:  e2e-tests, e2e
Powerslim
Fitnesse Slim implementation in PowerShell. PowerSlim makes it possible to use PowerShell in the acceptance testing
Stars: ✭ 49 (+36.11%)
Mutual labels:  test, test-automation
Ocaramba
C# Framework to automate tests using Selenium WebDriver
Stars: ✭ 234 (+550%)
Mutual labels:  test, test-automation
playwright-demos
playwright for scrapping and UI testing / automate testing workflows
Stars: ✭ 65 (+80.56%)
Mutual labels:  test-automation, e2e
arduino-ci-script
Bash script for continuous integration of Arduino projects
Stars: ✭ 25 (-30.56%)
Mutual labels:  test, test-automation
Swagger meqa
Auto generate and run tests using swagger/OpenAPI spec, no coding needed
Stars: ✭ 151 (+319.44%)
Mutual labels:  test, test-automation
Carina
Carina automation framework: Web, Mobile, API, DB
Stars: ✭ 549 (+1425%)
Mutual labels:  test, test-automation
Rest Assured
Java DSL for easy testing of REST services
Stars: ✭ 5,646 (+15583.33%)
Mutual labels:  test, test-automation
Softest
Recording Browser Interactions And Generating Test Scripts.
Stars: ✭ 208 (+477.78%)
Mutual labels:  test, e2e-tests
IridiumApplicationTesting
A&G Web Application Testing Suite
Stars: ✭ 19 (-47.22%)
Mutual labels:  e2e-tests, e2e

Jeust Retry

Motivation

E2E test failures due to reasons outside the domain of source code, including:

  1. Network timeouts
  2. Flaky endpoints etc.
  3. Login issues
  4. Flaky selenium selectors (bad code which is hard to diagnose)
  5. Whatever other mishaps, etc.

Setup

Create a run-config to pass into jest-retry

Example run

require('jest-retry')({
    debug: false,
    testDir: 'src/tests',
    testFilter: 'table-tests',
    // jest-junit is currently the only option
    outputTestResults: true,
    testResultsOutput: '.',

    /* Test retry options */
    flakyTestMock: false,
    flakyTestMockDir: 'src/mocks',
    flakyFailureMessages: ['Network timeout'],
    
    // Matches to test failures `testFilePath` 
    // These are still marked as fail, but does not contribute to jest exiting with failure status
    knownIssues: ['src/test/known-issue.test'],
    
    flakyNumRetries: 2, // 0 for disable retry pattern or Infinity for continue running until getting same results
       
    flakyMarkAll: false,
    flakyWaitBeforeRerun: 1000,
    // Jest options
    setupTestFrameworkScriptFile: 'jest-config.js',
    maxWorkers: 1,
    noStackTrace: false,
    silent: false,
});

Test

npm run test runs a short 2 test suite in which a failure occurs and is forced to pass on the second retry

Test output

☁  jest-retry [master] npm run test

> [email protected] test /code/jest-retry
> ./test/run.js

 PASS  test/always-pass.test.js
 FAIL  test/conditional-fail.test.js
  ● mocks/conditional-fail › conditionally fails

    expect(received).toBe(expected) // Object.is equality

    Expected value to be:
      false
    Received:
      true

      1 | describe('mocks/conditional-fail', async () => {
      2 |   it('conditionally fails', async () => {
    > 3 |     if (!process.env.SKIP) expect(true).toBe(false);
      4 |   });
      5 | });
      6 |

      at Object.it (test/conditional-fail.test.js:3:41)

Test Suites: 1 failed, 1 passed, 2 total
Tests:       1 failed, 1 passed, 2 total
Snapshots:   0 total
Time:        0.28s, estimated 1s
Ran all test suites.

flakyDictionaryCount: {
  "Expected value to be": 1
}

Retrying the following test suites:  [
  "/code/jest-retry/test/conditional-fail.test.js"
]
===============================================

 PASS  test/conditional-fail.test.js
  mocks/conditional-fail
    ✓ conditionally fails

Test Suites: 1 passed, 1 total
Tests:       1 passed, 1 total
Snapshots:   0 total
Time:        0.099s, estimated 1s
Ran all test suites.

All failures have now passed

Test retries result: true
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].