• Stars
    star
    481
  • Rank 91,384 (Top 2 %)
  • Language
    JavaScript
  • Created about 12 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Lightweight CSS regression testing

CSS Critic

NPM version A lightweight tool for regression testing of Cascading Style Sheets.

What?

One picture might say more than 1000 words:

CSS Critic testing the TodoMVC app

For background information watch the screencast or if you feel like playing around have a look at the runnable instance. This example project helps you get started with your own setup.

Why?

Your web stack should be fully testable. CSS Critic closes the gap in front end testing and makes HTML & CSS testable - no more broken UI. For example, make it supervise changes to your project's responsive styleguide so you know things are looking good.

How is it different to the other tools out there?

We believe that your UI will change often enough that a lightweight process on managing changes (near instant feedback, anyone?) is more important than a heavy-weight one which could offer tighter control. Also CSS Critic aims at bridging the gap between user experience (UX) people and (UI) developers. You probably won't find any easier way of sharing your UI tests than as the simple web page that CSS Critic basically is. And don't feel put down by the "CSS" bit, you may throw anything at it that can be converted into a simple image.

How to install?

$ npm install csscritic

See node_modules/csscritic/example/RegressionRunner.html for an example on how to take it from there.

How does it work?

CSS Critic checks your current layout constantly against a reference image you have provided in the past. If your layout breaks (or simply changes - CSS Critic can't tell) your tests fail.

Get started:

  1. Create a RegressionRunner.html similar to the one under example/ and put it with your code that is to be tested.

  2. Register your page under test via:

    csscritic.add({
        url: 'SOME_URL',  // link to the test case HTML document
        desc: 'some text' // optionally, a description of the test case (see API for even more options)
    });
  3. Serve the directory on a local webserver via python3 -m http.server and open the RegressionRunner.html in your favourite browser

  4. Now save the resulting image as future reference.

  5. Re-run the RegressionRunner.html and see your test passing. Congratulations.

What do I do if my test fails?

  1. Have a look at the diff image and visually inspect what has changed.

  2. If the change is an unwanted one fix your CSS,

  3. If deliberate accept the change (generating a new reference image).

Developing CSS Critic

For tests install Node.js and run

$ npm install && npm test

To see CSS Critic testing its own UI run

$ python3 -m http.server
$ open http://localhost:8000/test/RegressionRunner.html

Limitations

For more information see the FAQ and API.

Licensed under MIT. Maintained by @cburgmer. Copyright (c) 2012, 2013 ThoughtWorks, Inc.

More Repositories

1

rasterizeHTML.js

Renders HTML into the browser's canvas
JavaScript
2,451
star
2

cjklib

Han character library for CJKV languages
Python
147
star
3

buildviz

Transparency for your build pipeline's results and runtime
Clojure
108
star
4

json-path-comparison

Comparison of the different implementations of JSONPath and language agnostic test suite.
Shell
84
star
5

xmlserializer

xmlserializer serializes a DOM subtree or DOM document into XML/XHTML
JavaScript
36
star
6

upsidedown

Simple Python module that "flips" latin characters in a string to create an "upside-down" impression
Python
27
star
7

ayepromise

A teeny-tiny promise library
JavaScript
27
star
8

pdfserver

Pdfserver is a webservice that offers common PDF operations like joining documents, selecting pages or "n pages on one".
Python
17
star
9

jquery-shiftenter

Submit your textarea through a simple press on 'Enter' with jQuery
JavaScript
14
star
10

inlineresources

Inlines style sheets, images, fonts and scripts in HTML documents.
JavaScript
13
star
11

build-facts

Dump your build pipeline's data for inspection
Clojure
13
star
12

jp

A simpler jq, and with JSONPath
Shell
11
star
13

surf

Old Git fork of the SuRF Object RDF Mapper
Python
10
star
14

greenyet

Microservices status dashboard
Clojure
10
star
15

csscritic-examples

Helping you set up CSS Critic with your project
JavaScript
9
star
16

css-font-face-src

A CSS @font-face src property value parser
TypeScript
8
star
17

eclectus

Han character dictionary
Python
7
star
18

hwr

Clone of Tegaki project
Python
6
star
19

tegaki

Chinese and Japanese Handwriting Recognition
Python
6
star
20

deniz

A simple web app for browsing RDF data
JavaScript
6
star
21

sparqlprotocolproxy

Small SPARQL protocol proxy server
Python
4
star
22

tinycors

A dead simple CORS proxy
JavaScript
2
star
23

django-wikify

django-wikify is a lightweight module to turn your static Django model views into full wiki pages.
Python
2
star
24

slow-promise

Slow down your promises
JavaScript
2
star
25

basic-auth-proxy

A tiny proxy forcing basic-auth
JavaScript
1
star
26

html2xhtml.js

HTML to XHTML converter
JavaScript
1
star