You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

ptor-xunit-grep-builder

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ptor-xunit-grep-builder

Given XML reports from protractor, this library will construct the `grep` param to run the failing tests

0.0.11
latest
npmnpm
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

Description

Given XML reports from protractor, this library will construct the grep param to run the failing tests

Supports sharded configuration

HOW TO USE

install this library

npm install -g ptor-xunit-grep-builder

configure your protractor to export reports to xml (in onPrepare() phase )

// for sharded configuration
jasmine.getEnv().addReporter(new jasmineReporters.JUnitXmlReporter({
  consolidateAll: true,
  savePath: savePath + '/each',
  filePrefix: 'failed-test-' + uuid()
}));

// for regular configuration
jasmine.getEnv().addReporter(new jasmineReporters.JUnitXmlReporter({
  consolidateAll: true,
  savePath: savePath
}));

// alternatively, to have support for specs as well
// tested on configuration for running in parallel.
return global.browser.getProcessedConfig().then((config) => {
  const filename = () => {
    try {
      return config.specs[0].split('/').slice(-1)[0]; // return entire name (e.g. name.ptor.js) - this will be appended with .xml later on
    } catch (e) {
      return 'failed-test-' + uuid();
    }
  };
  const filenameValue = filename();
  global.jasmine.getEnv().addReporter(new jasmineReporters.JUnitXmlReporter({
    consolidateAll: true,
    savePath: savePath + '/each/',
    filePrefix: filenameValue
  }));

  logger.info('filename is', filenameValue);
});

add a retry code to you build script - her is an example

#!/usr/bin/env bash

print_attempt(){
    echo "#########################################################################################"
    echo "                          attempt ${i}                                                   "
    echo "#########################################################################################"
}

clean_reports () {
rm -rf ./reports/protractor/**/failed-test-*.xml
}

run_tests () {
    print_attempt
    echo PTOR_SUITE=${PTOR_SUITE}
    GREP_PARAMS=`ptor-xunit-grep-builder --tests --files=./reports/protractor/*/each/*.xml`
    echo "count of all tests"
    ptor-xunit-grep-builder --count --tests --files=./reports/protractor/*/each/*.xml
    SPECS_PARAMS=`ptor-xunit-grep-builder --filenames --files=./reports/protractor/*/each/*.xml`
    echo "GREP PARAMS=${GREP_PARAMS}"
    echo "SPECS PARAMS=${SPECS_PARAMS}"

    if  [ "$GREP_PARAMS" = "" ]; then
        echo "ERROR::: grep params is empty but retrying..."
        exit 1
    fi

    if  [ "$SPECS_PARAMS" = "" ]; then
        echo "ERROR::: specs params is empty but retrying..."
        exit 1
    fi

    clean_reports
    ./node_modules/.bin/protractor --specs=${SPECS_PARAMS} --grep="${GREP_PARAMS}" protractor.conf.js
}

first_run () {
    print_attempt
    clean_reports
    ./node_modules/.bin/protractor --suite=${PTOR_SUITE} protractor.conf.js
}
i=1
# run first time and then retry over and over again
first_run || ( for i in 2 3 4 5 6 7 8 9; do run_tests $i && break || sleep 5; done )

Roadmap

  • tests
  • Make usable with less boilerplate
  • buzz with post and publishing

FAQs

Package last updated on 23 Jan 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.