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

@soyjavi/testing-react

v0.1.6

Published

Simple and complete testing utilities that encourage good universal testing practices

Downloads

1

Readme

💾 testing-library

Simple and complete testing utilities that encourage good universal testing practices

📦 Setup

Add the package in your project:

yarn add @soyjavi/testing-react

Visual Regression Testing helper

Regression Testing is used to verify that any system changes do not interfere with existing features and/or code structure. There's a reason regression tests are part of almost every test suite in software development. It is common for devs to change or add a section of code, and having it unintentionally disrupt something that was previously working just fine.

Visual Regression Testing applies the same logic but confines testing to the visual aspects of the software. In other words, it checks that code changes do not break any aspect of the software's visual interface.

A visual regression test checks what the user will see after any code changes have been executed by comparing screenshots taken before and after code changes. This is why visual regression tests are also sometimes called visual snapshot tests.

How to create a visual test

To facilitate the development of your visual tests, we have created the describe function which allows you to configure the properties we want to test. Let's see an example with the <Button> component:

Button.visual.js

import { describeVisual } from '@soyjavi/testing-react';

describeVisual({
  component: 'Button',
  props: {
    default: undefined,
    busy: true,
    text: 'children',
    disabled: true,
    icon: 'close',
    large: true,
    small: true,
    upperCase: false,
    'variant:PRIMARY': 'PRIMARY',
    'variant:SECONDARY': 'SECONDARY',
    'variant:CIRCULAR_PRIMARY': 'CIRCULAR_PRIMARY',
    'variant:CIRCULAR_SECONDARY': 'CIRCULAR_SECONDARY',
    wide: false,
  },
});

Snapshots of Button.visual.js

If we look closely, we are simply setting a value for each of the properties of the <Button> component. In case you need to test more than one value for the same property, you can use the pattern nameProperty:value as the name of the property. You can see it in:

...
'variant:PRIMARY': 'PRIMARY',
'variant:SECONDARY': 'SECONDARY',
'variant:CIRCULAR_PRIMARY': 'CIRCULAR_PRIMARY',
'variant:CIRCULAR_SECONDARY': 'CIRCULAR_SECONDARY',
...

The describe function also allows you to run your visual tests on different device sizes. To do this we simply have to set the screen property with the size we need (S, M or L):

Box.visual.js

describeVisual({
  component: 'Box',
  props: {
    default: undefined,
  },
  screen: 'M',
});

Snapshots of Box.visual.js

How to run your visual tests

First you need to have the Storyteller running:

yarn start

In another terminal you must execute the script:

yarn test:visual

Screen Shot 2021-08-24 at 7 37 02 AM

In the event that you have modified the scaffold of a certain component, you will most likely have to update its Image Snapshots, for this you simply have to execute the script of package.json:

yarn test:visual -u