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

goodlooks

v1.0.2

Published

Visually Validate Playwright Tests Without Flaky Selectors

Downloads

7

Readme

GoodLooks Logo

Visually Validate Playwright Tests Without Flaky Selectors

Static selectors break with code changes and can't prove that a site "looks good". Is that button really missing or was the id changed? Is the site responsive on mobile? Is the correct image showing? These kinds of tests are impossible to validate with selectors alone and take a lot of time to test manually. GoodLooks.ai lets you visually validate your web pages with natural language prompts instead of selectors.

Check out our other products: TestDriver.ai and Dashcam.io.

Quickstart

Install via NPM.

npm install goodlooks

Use in Playwright tests!

const { test, expect, devices } = require("@playwright/test");
const goodlooks = require("goodlooks");
goodlooks.configure("YOUR_API_KEY");
expect.extend(goodlooks);

Note that these examples use a demo key that gets rotated weekly; you'll want to create your own API KEY.

Examples

Element Visiblity

Validate that a cookie banner shows up.

Framer.com Cookie Banner

const { test, expect } = require("@playwright/test");

const goodlooks = require("goodlooks");
goodlooks.configure("YOUR_API_KEY");

expect.extend(goodlooks);

test("framer", async ({ page }) => {
  await page.goto("https://framer.com/");
  await page.waitForTimeout(5000);
  await expect(page).goodlooks("A request to enable cookies shows up");
});

Mobile Responsiveness

Ensure a page is rendering mobile view properly.

CNN.com on mobile

const { test, expect, devices } = require("@playwright/test");

const goodlooks = require("goodlooks");
goodlooks.configure("YOUR_API_KEY");

expect.extend(goodlooks);

test("is mobile responsive", async ({ page }) => {
  page.setViewportSize(devices["iPhone X"].viewport);
  await page.goto("https://cnn.com/");

  await expect(page).goodlooks("should be mobile responsive");

});

Application State

Validate that the video player is not playing.

Rick Astley YouTube

const { test, expect } = require("@playwright/test");

const goodlooks = require("goodlooks");
goodlooks.configure("YOUR_API_KEY");

expect.extend(goodlooks);

test("rickroll", async ({ page }) => {
  await page.goto("https://www.youtube.com/watch?v=dQw4w9WgXcQ");
  await expect(page).goodlooks("video is not playing");
});

Color

Ensure a page renders correct image contents via img or canvas.

CleanShot 2024-03-08 at 12 46 45

const { test, expect, devices } = require("@playwright/test");

const goodlooks = require("goodlooks");
goodlooks.configure("YOUR_API_KEY");

expect.extend(goodlooks);

test("ycombinator", async ({ page }) => {
  await page.goto("https://news.ycombinator.com");
  await expect(page).goodlooks(
    "there is an orange strip at the top of the page"
  );
});

Image Contents

Ensure a page renders correct image contents via img or canvas.

Eloquent Javascript

const { test, expect, devices } = require("@playwright/test");

const goodlooks = require("goodlooks");
goodlooks.configure("YOUR_API_KEY");

expect.extend(goodlooks);

test("correct image appears", async ({ page }) => {
  await page.goto("https://eloquentjavascript.net/");
  await expect(page).goodlooks("there is bird on this page");
});

Opinionated Image Contents

Ensure a diverse representation of people appears on the page. Of course, this judgement is left up to AI.

CleanShot 2024-03-08 at 11 55 13

const { test, expect } = require("@playwright/test");
const goodlooks = require("goodlooks");
goodlooks.configure("YOUR_API_KEY");

test("diversity", async ({ page }) => {
  await page.goto("https://diversityequityinclusion.com/about/");
  await expect(page).goodlooks("diverse people show up");
});

Debugging

It seems like GoodLooks is wrong? I'm sure the element exists that I'm checking for.

Run your playwright tests in UI mode:

npx playwright test --ui
  1. Check the log to see the time frame where the goodlooks check is called. Hover over that.
  2. A red highlight will appear in the Playwright UI, showing you the GUI state when the screenshot was taken
  3. You can also see the debug logs within the Console or Error tabs. CleanShot 2024-03-08 at 12 27 49

What part of the page is checked?

Only the visible part of the page is checked, not the full page. You must scroll to check other page parts.

What are the limits?

The AI is great at identifying what is in an image, but it's not great at identifying where those things are in relation to other things. For example, don't ask GoodLooks to count items to validate their position on the screen.

How do I manage my subscription

You can manage your subscription here.

Other Projects