npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

jest-retry-fixed

v1.0.27

Published

UI E2E Retry Pattern for Jest

Downloads

20

Readme

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