Coder Social home page Coder Social logo

spazbg / circleci-wdio-rerun-fix Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 7 KB

Bash script that fixes the issue with CircleCI's "Rerun failed tests" feature when using the WebdriverIO (WDIO) test framework by removing the file:// prefix from feature file paths before executing the tests

Shell 100.00%

circleci-wdio-rerun-fix's Introduction

Circleci WDIO Script

This repository contains a Bash script circleci-wdio.sh that facilitates the execution of WebdriverIO (WDIO) tests on CircleCI while addressing an issue with the "Rerun failed tests" feature. The script is designed to handle the file path formatting required by WDIO, ensuring that the "Rerun failed tests" functionality works correctly.

Background

When using the "Rerun failed tests" feature in CircleCI with the WebdriverIO v8 test framework, the rerun command may not correctly handle file paths. Specifically, WDIO adds the file:// prefix to feature file paths, causing the "Rerun failed tests" functionality to fail as it attempts to find files with the file:// prefix in the test folder.

Solution

The circleci-wdio.sh script addresses this issue by removing the file:// prefix from the feature file paths before executing the WDIO tests. This ensures that the "Rerun failed tests" feature can correctly locate and rerun the failed tests.

Usage

  1. Copy the circleci-wdio.sh script into your project's directory (e.g., app/e2e).
  2. In your CircleCI configuration file, include the following steps:
steps:
  - run:
      name: Make script executable
      command: chmod +x ./circleci-wdio.sh
      working_directory: app/e2e
  - run:
      name: Run yarn << parameters.script >> in << parameters.script >>
      environment:
        DEBUG: "true"
        WEB: "true"
        MOCK: "true"
      command: |
        mkdir -p reports
        circleci tests glob "features/**/*.feature" | circleci tests run --command="xargs ./circleci-wdio.sh web " --verbose --split-by=timings
      working_directory: app/e2e
  1. Replace web in the circleci tests run command with the appropriate platform (web, ios, or android) based on your testing requirements.

Script Details

The circleci-wdio.sh script performs the following steps:

  1. Accepts a platform argument (web, ios, or android) to determine the appropriate WDIO configuration file and Cucumber tag.
  2. Iterates over the provided feature file paths.
  3. Removes the file:// prefix from each feature file path using sed.
  4. Constructs the WDIO command with the appropriate configuration file, Cucumber tag, and feature file paths.
  5. Executes the WDIO command using yarn wdio run.

By incorporating this script into your CircleCI workflow, you can ensure that the "Rerun failed tests" feature works correctly with your WDIO test framework

Solution 2

The remove_prefix.sh script addresses an additional issue where the file:// prefix appears in the XML reports generated after the execution of tests. This script removes the file:// prefix from the value and file attributes in the XML report files.

Usage

  1. Copy the remove_prefix.sh script into your project's directory (e.g., app/e2e).

  2. In your CircleCI configuration file, include the following step after the test execution:

    steps:
      - run:
          name: Remove file:// prefix from JUnit XML reports
          path: app/e2e/
          command: |
            chmod +x ./remove_prefix.sh
            ./remove_prefix.sh
          when: always
      - store_test_results:
          path: ~/project/app/e2e/reports

Script Details

The remove_prefix.sh script performs the following steps:

  1. Specifies the path to the XML report files (reports directory).
  2. Iterates over each XML file in the directory.
  3. Removes the file:// prefix from the value and file attributes using sed.
  4. Updates the XML files in place.

By incorporating these scripts into your CircleCI workflow, you can ensure that both the "Rerun failed tests" feature and the XML reports work correctly with your WDIO test framework.

circleci-wdio-rerun-fix's People

Contributors

spazbg avatar

Watchers

 avatar

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.