Giter Club home page Giter Club logo

argos-ember's Introduction

@argos-ci/ember

Argos visual testing SDK for Ember applications.

Prerequisites

To get most out of this guide, you'll need to:

Getting started

1. Install

npm install --save-dev puppeteer @argos-ci/ember

2. Configure testem

Use argos-chrome as browser in your testem configuration.

// testem.js
"use strict";

const path = require("path");

const argosChrome = path.resolve(__dirname, "node_modules/.bin/argos-chrome");

module.exports = {
  test_page: "tests/index.html?hidepassed",
  launch_in_ci: ["Chrome"],
  browser_paths: {
    Chrome: argosChrome,
  },
};

3. Take screenshots

Use argosScreenshot to take screenshot of your application.

import { module, test } from "qunit";
import { visit } from "@ember/test-helpers";
import { setupApplicationTest } from "ember-qunit";
import { argosScreenshot } from "@argos-ci/ember";

module("Home", function (hooks) {
  setupApplicationTest(hooks);

  test("takes a screenshot of the homepage", async function () {
    await visit("/");
    await argosScreenshot("home");
  });
});

4. Setup your CI

Add this command to your CI pipeline to upload the screenshots to Argos.

npm exec -- argos upload --token <ARGOS_TOKEN> ./screenshots

argos-ember's People

Contributors

gregberge avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

seanpm2001

argos-ember's Issues

`prefers-reduced-motion` not set to `reduce` results in screenshots being taken mid-animation.

Hello!

I'm trying to take a screenshot of a page that has a fade-in animation on render.

I played around with CSS resets, but I couldn't reach a satisfactory result. The screenshot is being taken mid-animation:

I was finally able to take a good screenshot by emulating prefers-reduced-motion="reduce" on the Puppeteer page object:

// node_modules/@argos-ci/ember/run-chrome.mjs

  app.post("/screenshot", express.json(), async (req, res) => {
    try {
      // Take a screenshot of the page
      const element = await page.$("#ember-testing");
      if (!element) {
        throw new Error("No #ember-testing element found");
      }
      const { name, ...options } = req.body;

+      page.emulateMediaFeatures([
+        { name: "prefers-reduced-motion", value: "reduce" },
+      ]);

      await argosScreenshot(page, name, {
        element,
        ...options,
      });
      res.sendStatus(200);
    } catch (error) {
      res.send(error.stack);
      console.error(error);
      res.sendStatus(500);
    }
  });

In the snippet, prefers-reduce-motion is set to reduce by default, which seems consistent with the fact that animations are not something that you might want to do visual regression testing on.

I think this could also be an option, but it gets filtered out somewhere down the line. I believe by the TypeScript configuration since it's not part of PuppeteerArgosScreenshotOptions.

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.