npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

blue-harvest

v0.3.1

Published

protractor helpers

Downloads

1,014

Readme

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.