Git Product home page Git Product logo

backstop-retry-failed-scenarios's Introduction

backstop-retry-failed-scenarios

A wrapper command to retry failed scenario for BackstopJS.
It parses report.json, extract failed tests, and rerun with --filter option, and rewrite result file.
This is useful when your tests are unstable.

FEATURES

  • Invoke specified test command
  • Generate filter option from failed tests
  • Reorganize each failed reports to latest one status
    • Supports HTML report, JSON report, CI report.

EXAMPLE

This endpoint returns random emoji from three emojis(๐Ÿ˜€, ๐Ÿ˜‡, ๐Ÿ˜).
Each try may fail, but retrying failed tests will pass all test.

$ cd examples/retry
$ backstop reference
$ npx backstop-retry-failed-scenarios

examples/retry/images/try.gif

HOW TO RUN

Instead of backstop test, run backstop-retry-failed-scenarios and set command, retry count, config path.

$ npm install -g backstop backstop-retry-failed-scenarios
$ backstop init
$ backstop reference
$ backstop-retry-failed-scenarios --retry 5 --command 'backstop test' --config backstop.js

Instead of npm install, you can pull hitode909/backstop-retry-failed-scenarios from DockerHub.
Its image is based on backstopjs/backstopjs, so you can execute backstop directly from docker run hitode909/backstop-retry-failed-scenarios.

$ docker pull hitode909/backstop-retry-failed-scenarios
$ docker run --rm -v $(pwd):/src hitode909/backstop-retry-failed-scenarios backstop init
$ docker run --rm -v $(pwd):/src hitode909/backstop-retry-failed-scenarios backstop reference
$ docker run --rm -v $(pwd):/src hitode909/backstop-retry-failed-scenarios backstop-retry-failed-scenarios

If you want to recreate references every time, Please set --reference-command option. This will do like this.

  1. create all references
  2. run all tests
  3. create references for failed tests on 2.
  4. run tests for failed tests on 2.

This is useful when your reference refers to production instead static file, and test refers to staging environment.

$ backstop init
$ backstop-retry-failed-scenarios --reference-command 'backstop reference' --command 'backstop test' --config backstop.js

OPTIONS

  --retry             number Trial count. default: 2(Run once, retry once). minimum: 2
  --config            string Path to config file. default: backstop.json
  --command           string Command to run test. default: backstop test
  --reference-command string Command to create reference before testing. Default: null (Do not create reference before test).
  --output-profile    string Path to profiler output file. If present, measure the execution time and output the report as JSON.

backstop-retry-failed-scenarios's People

Contributors

hitode909 avatar mizdra avatar renovate-bot avatar werewolfas avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

backstop-retry-failed-scenarios's Issues

Unable to use command backstop-retry-failed-scenarios with custom json

When I try to run retry I get below error

retry % backstop-retry-failed-scenarios --retry 5 --config="retry.json"
Running(1/5) backstop test

BackstopJS v5.3.0

# internal/modules/cjs/loader.js:883

throw err;

^

Error: Cannot find module '/Users/***/Desktop/backstop_latest/retry/backstop.json'

Require stack:

- /usr/local/lib/node_modules/backstopjs/core/util/makeConfig.js

- /usr/local/lib/node_modules/backstopjs/core/runner.js

- /usr/local/lib/node_modules/backstopjs/cli/index.js

at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)

at Function.resolve (internal/modules/cjs/helpers.js:94:19)

at loadProjectConfig (/usr/local/lib/node_modules/backstopjs/core/util/makeConfig.js:44:36)

at makeConfig (/usr/local/lib/node_modules/backstopjs/core/util/makeConfig.js:62:38)

at module.exports (/usr/local/lib/node_modules/backstopjs/core/runner.js:5:16)

at main (/usr/local/lib/node_modules/backstopjs/cli/index.js:40:5)

at Object. (/usr/local/lib/node_modules/backstopjs/cli/index.js:8:1)

at Module._compile (internal/modules/cjs/loader.js:1063:30)

at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)

at Module.load (internal/modules/cjs/loader.js:928:32) {

code: 'MODULE_NOT_FOUND',

requireStack: [

'/usr/local/lib/node_modules/backstopjs/core/util/makeConfig.js',

'/usr/local/lib/node_modules/backstopjs/core/runner.js',

'/usr/local/lib/node_modules/backstopjs/cli/index.js'

]

}

command does not work in windows

I found that this command does not work in windows.

In my case, after 2 failed scenarios the script tried to execute this command

> backstop.cmd test --filter '^(Scenario1|Scenario2)$'`

It failed with this output

'Scenario2)$'' is not recognized as an internal or external command,
operable program or batch file.

I found that chaning single quotes to double quotes fixed the issue in my environment. Unfortunately I can't test in the moment, so I can't tell if it works correctly there.

Again, in my windows environment, changing the line 68 in Runner.js from:

filterOption = `--filter '${this.filter}'`;`

to:

filterOption = `--filter "${this.filter}"`; `

Solved the issue.

Append --config option to command when config option is settled.

Setting option is complexed when config path is not backstop.json. Appending --config option seems useful.

# before
$ backstop-retry-failed-scenarios --reference-command 'backstop reference --config backstop.js' --command 'backstop test --config backstop.js' --config backstop.js
# after
$ backstop-retry-failed-scenarios --reference-command 'backstop reference' --command 'backstop test' --config backstop.js

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Rate-Limited

These updates are currently rate-limited. Click on a checkbox below to force their creation now.

  • Update dependency @types/xml2json to v0.11.6
  • Update actions/cache action to v4
  • Update actions/checkout action to v4
  • Update actions/setup-node action to v4
  • Update dependency @types/node to v20
  • Update dependency command-line-args to v6
  • Update dependency command-line-usage to v7
  • Update dependency eslint-plugin-jest to v28
  • Update dependency gts to v5
  • Update dependency typescript to v5
  • ๐Ÿ” Create all rate-limited PRs at once ๐Ÿ”

Edited/Blocked

These updates have been manually edited so Renovate will no longer make changes. To discard all commits and start over, click on a checkbox.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

dockerfile
Dockerfile
  • backstopjs/backstopjs 6.0.4
github-actions
.github/workflows/ci.yml
  • actions/checkout v3
  • actions/setup-node v2
  • actions/cache v2
npm
package.json
  • command-line-args 5.2.1
  • command-line-usage 6.1.1
  • escape-string-regexp 4.0.0
  • xml2json 0.12.0
  • @types/command-line-args 5.2.0
  • @types/command-line-usage 5.0.2
  • @types/jest 26.0.24
  • @types/node 13.13.46
  • @types/xml2json 0.11.4
  • eslint-plugin-jest 25.7.0
  • gts 3.1.0
  • jest 27.5.1
  • test-fixture 2.4.1
  • ts-jest 27.1.3
  • typescript 4.6.2
  • node >=10.18.1

  • Check this box to trigger a request for Renovate to run again on this repository

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Error type: undefined. Note: this is a nested preset so please contact the preset author if you are unable to fix it yourself.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.