Socket
Socket
Sign inDemoInstall

protractor-smartrunner

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

protractor-smartrunner - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

4

lib/smartrunner-results.d.ts

@@ -0,1 +1,2 @@

import { Logger } from 'protractor/built/logger';
export interface TestResult {

@@ -16,6 +17,7 @@ retries: number;

export declare class SmartRunnerResults {
private logger;
private smartRunDir;
private results;
private affectedSuites;
constructor(outputDirectory: string, repoHash: string);
constructor(outputDirectory: string, repoHash: string, logger: Logger);
load(): void;

@@ -22,0 +24,0 @@ set(suiteName: string, testName: string, passed: boolean, duration: number): void;

@@ -5,10 +5,10 @@ "use strict";

const path_1 = require("path");
const chalk_1 = require("chalk");
const fs = require('fs-extra');
const filenamify = require('filenamify');
class SmartRunnerResults {
constructor(outputDirectory, repoHash) {
constructor(outputDirectory, repoHash, logger) {
this.logger = logger;
this.affectedSuites = {};
if (!(repoHash === null || repoHash === void 0 ? void 0 : repoHash.length)) {
console.log(chalk_1.red('ERROR: repoHash is not defined, terminating...'));
this.logger.error('🛑 ERROR: repoHash is not defined, terminating...');
process.exit(1);

@@ -44,3 +44,3 @@ }

if (updatedSuiteNames.indexOf(suite) !== -1) {
console.log(`Suite (${suite}) was affected by this thread, writing to filesystem.`);
this.logger.info(`ℹ️ Suite (${suite}) was affected by this thread, writing to filesystem.`);
const fileName = path_1.resolve(this.smartRunDir, filenamify(`./${suite}.json`));

@@ -47,0 +47,0 @@ fs.outputJsonSync(fileName, { [suite]: this.results[suite] }, { spaces: 4 });

export interface SmartRunnerOptions {
outputDirectory?: string;
passedMessagePrefix?: string;
repoHash: string;

@@ -8,2 +9,3 @@ }

private results;
private logger;
static apply(options: SmartRunnerOptions): SmartRunner;

@@ -10,0 +12,0 @@ static withOptionalExclusions(filePath: string): {

@@ -6,5 +6,8 @@ "use strict";

const smartrunner_reporter_1 = require("./smartrunner-reporter");
const logger_1 = require("protractor/built/logger");
const fs = require('fs-extra');
const LOGGER_ID = 'smartrunner';
const DEFAULT_OPTIONS = {
outputDirectory: './.protractor-smartrunner',
passedMessagePrefix: '🟢 previously passed:'
};

@@ -14,3 +17,4 @@ class SmartRunner {

this.options = options;
this.results = new smartrunner_results_1.SmartRunnerResults(this.options.outputDirectory, this.options.repoHash);
this.logger = new logger_1.Logger(LOGGER_ID);
this.results = new smartrunner_results_1.SmartRunnerResults(this.options.outputDirectory, this.options.repoHash, this.logger);
this.results.load();

@@ -23,2 +27,3 @@ this.setupJasmine();

static withOptionalExclusions(filePath) {
const logger = new logger_1.Logger(LOGGER_ID);
const cliGrepped = process.argv.some((argument) => /^-g=/.test(argument) || /^--grep=/.test(argument));

@@ -28,2 +33,3 @@ if (!cliGrepped && fs.existsSync(filePath)) {

if (exclusions.length) {
logger.info('🚫 Exclusion patterns: ', exclusions.join(', '));
return {

@@ -44,2 +50,5 @@ grep: exclusions.join('|'),

const testPassedInPreviousRun = this.results.get(suiteName, testName);
if (testPassedInPreviousRun.passed) {
this.logger.info(`${this.options.passedMessagePrefix} ${suiteName} ${testName}`);
}
return !testPassedInPreviousRun.passed && oldSpecFilter(spec);

@@ -46,0 +55,0 @@ };

{
"name": "protractor-smartrunner",
"version": "1.0.0",
"version": "1.1.0",
"description": "Protractor utility for keeping track of passed/failed tests between runs. Works together with protractor-retry.",

@@ -34,3 +34,6 @@ "main": "lib/index.js",

"fs-extra": "8.1.0"
},
"peerDependencies": {
"protractor": "~7.0.0"
}
}

@@ -17,7 +17,25 @@ # Protractor Smartrunner

This feature records the status (`passed` or `failed`) of every test run, and stores it in the filesystem.
After the first run, during every subsequent protractor execution, it only lets the failed tests to run, every previously passed tests will be skipped.
This feature records the status of every test run, and stores it in the filesystem (in s directory specified in its configuration).
This can be particularly handy and performant in CI environments, if you happen to have flaky tests, or you know that some of your tests might have failed, not because of your changeset, but e.g.: lack of, shortage of or bug in the related BE services. This way, fixing the BE, you can rerun only those tests which failed.
Every test has the following status object stored in json files:
```json
{
"suite-name": {
"test-name": {
// Number of test retries before is has passed, if passed at all
"retries": 0,
// Whether it has passed or not
"passed": true,
// In case if it is passed, what was the duration of the last (successful) execution
"duration": 399
},
...
},
...
}
```
After the first run, during every subsequent protractor execution, this feature only lets the failed tests to run, every previously passed tests will be skipped (and displayed with the `✅ previously passed:` prefix, which is configurable, see the [options](#options)).
This can be particularly handy and performant in CI environments, if you happen to have flaky tests, or you know that some of your tests might have failed, not because of your changeset, but e.g.: shortage of BE service or bug in the related BE service. This way, fixing the BE, you can rerun only those tests which failed.
Obviously, if you change something in your code (new changeset), it makes sense to rerun all of the tests, not just the previously failed ones. That is why, the **protractor-smartrunner** is bound to your codebase snapshot identifier (`repoHash`), which in case of git, make sense to be the hash of your current `HEAD`.

@@ -61,3 +79,4 @@

interface SmartRunnerOptions {
outputDirectory?: string; // defaults to './.protractor-smartrunner'
outputDirectory?: string; // default: './.protractor-smartrunner'
passedMessagePrefix?: string; // default: '✅ previously passed:'
repoHash: string;

@@ -64,0 +83,0 @@ }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc