Git Product home page Git Product logo

blue-harvest's Introduction

blue-harvest

Install

You can npm to install the package: npm install blue-harvest --save-dev, or if you are using Yarn, yarn add blue-harvest -D

Writing Tests

Configurations

In order for you to use async await in the tests, the following line

SELENIUM_PROMISE_MANAGER: false;

should be added to the protractor.conf.js file.

To regulate the resolution of the screenshots, add

onPrepare() {
    browser.driver.manage().window().setSize(1366, 1024);
    jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
  }

in protractor.conf.js, inside the config block.

Comparing Screenshots

To test if a page has changed from a previous screenshot:

let result =  await blueharvest.compareScreenshot(
                   await browser.takeScreenShot(), pathToGolden);

The difference between the two screenshots will be highlighted in pink.

Updating Reference Screenshots

When a change in a page is expected and not a regression, you can update the reference screenshots by setting UPDATE_GOLDENS=1 when you run the tests. In this case, if any test fails, blue-harvest will update the reference image with the new one. Only tests involving the reference screenshots (goldens) are required. You can edit the specs in protractor.conf.js so only necessary tests are run in an update.

In a Linux system, you can simply run UPDATE_GOLDENS=1 npm run e2e to update the reference screenshots. In a windows environment where the command cannot be directly run, you can put it in a shell file and add a npm script that runs bash ./filename.sh to update the reference screenshots.

Adding Masks

If there is a part on a page that should be ignored in the screenshot tests, you can add a coloured mask to a certain element before you take the screenshot so it will not be compared each time the tests run. addMask() returns the mask element, which can be passed to removeMask() to be removed.

const e = element(by.css('element_to_ignore'));
const mask = await blueharvest.addMask(e, 'gray', 99999, 10, 20, 1.1);
const screenshot = await browser.takeScreenShot();
blueharvest.removeMask(mask);

The default z-index for the mask element is 10000. An optional zIndex argument can be passed to addMask() if you would like to increase the value of a mask's z-index. If the mask appears to be off the desired place, you can pass optional xOffset, yOffset and sizeMultiplier arguments to addMask() to move/shape the mask manually.

blue-harvest's People

Contributors

awang-copperleaf avatar cnishina avatar fabiendehopre avatar heathkit avatar rupamroy 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.