GithubHelp home page GithubHelp logo

asgaardlab / canvas-visual-bugs-testbed Goto Github PK

View Code? Open in Web Editor NEW
7.0 3.0 1.0 5.64 MB

Visual testing framework for PixiJS applications

Home Page: https://asgaardlab.github.io/canvas-visual-bugs-testbed/

License: MIT License

Python 65.72% TypeScript 24.47% Shell 2.11% JavaScript 7.70%
automated-testing canvas html5-canvas pixijs visual-testing

canvas-visual-bugs-testbed's Introduction

Visual testing for PixiJS applications

Automated visual testing framework for PixiJS applications. Early in development and does not yet work for all PixiJS apps (see Issues).

Note: To access the replication package for our paper "Automatically Detecting Visual Bugs in HTML5 <canvas> Games":

  • download the source from the p1 tag
  • download the data from Zenodo

Features

  • Collect snapshots from a PixiJS application; snapshots contain a screenshot paired with a scene graph
  • Perform automatic visual comparisons between oracles (generated during the test) and the objects rendered to the <canvas>
  • Supports automated test scripts written with Playwright in TypeScript

Note: To detect visual bugs, must set baseline (acceptable) error scores and then perform regression testing. This functionality will be added to the framework in a future release.

Prerequisites

Python (v3.4+)

Download and install the latest version of Python from this link. After installing Python, ensure Python's package manager (Pip) is installed by running the command:

python3 -m pip install ---upgrade pip

Node.js

Using the instructions found at this link, first install Node Version Manager (nvm), and then use nvm to install Node and Node Package Manager (npm).

Installation

  1. Download the latest release from the releases page
  2. Unzip the folder and place it inside your test directory
  3. Open the folder in your terminal and run the command npm install -D

Note: Initial installation may take a long time due to Python dependencies

Usage

  1. Collect snapshots by instrumenting automated test scripts
  2. Run visual tests on collected snapshots with Python script
  • Snapshot name needs to be known on both ends

1. Collecting snapshots

  • instrument your test code to capture snapshots, which are pairs of (screenshot, scene graph)
  • sampling API requires reference to Playwright browser Page instance
  • sampling API requires call to inject into the Page instance before samples can be taken

Importing:

import { PixiSamplerPlaywright } from 'pixi-visual-test/sampling/PixiSamplerPlaywright'

Instantiating:

/** @param {playwright.Page} page: Playwright browser page where PixiJS app is running */
const sampler = new PixiSamplerPlaywright(page, 'test/snapshots')

Injecting:

await sampler.startExposing();

Sampling:

await sampler.takeSnapshot('<name_of_snapshot>');

2. Running visual tests

Run python3 ./pixi-visual-test test/snapshots/<name_of_snapshot>

Examples

See test/ directory for a bare minimum example test script made for our toy example PixiJS game.

To run the example, enter the command npm run test from the root directory of this repository.

canvas-visual-bugs-testbed's People

Contributors

anon-ase avatar dependabot[bot] avatar finlaymacklon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

fabiopetrillo

canvas-visual-bugs-testbed's Issues

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.