Coder Social home page Coder Social logo

jamesives / front-end-visual-comparison-tool Goto Github PK

View Code? Open in Web Editor NEW
16.0 4.0 4.0 9.02 MB

๐Ÿ”ฎ๐Ÿ”ฌFront-End testing tool which can be used to create a side by side visual comparison between your live site and local site.

Home Page: https://jamesiv.es/nodejs/2018/06/26/creating-a-visual-comparison-tool-for-front-end-developers

License: MIT License

JavaScript 97.70% HTML 2.14% CSS 0.16%
visual-regression end-to-end-testing visual comparison frontend-testing front-end-testing testing poc

front-end-visual-comparison-tool's Introduction

Front-End Visual Comparison Tool ๐Ÿ”ฎ๐Ÿ”ฌ

This application runs a side by side visual comparison between the Front-End of your local developer environment and your production site with Chrome. Once the tests have concluded you'll be able to view the comparison side by side in the applications interface.

Installation Steps ๐Ÿ’ฝ

First you'll need to either clone this repository, or simply download it as a zip.

This project is database driven so test data can be persisted, therefore you'll need to start up a local MongoDB database and create/import the path into a file called config/database.config.js like so:

module.exports = {
  url : 'mongodb://localhost:27017/testdb'
};

Once you've added your database path you can run the following commands in order. This will install the required dependencies for the client and the Node service and then start the service.

$ npm install && cd ./client/ && npm install && cd ../
$ npm start

Once the service is started you can access the local interface at http://localhost:3000. The API service runs on port 9090.

Creating/Running a Test ๐Ÿ“

Within the interface you can add a test by clicking the Create Test option within the pullout menu. On the Create Test page you'll be prompted to fill in multiple fields of data.

Option Description Required
Name This should represent the name of your test. For example Blog Page or something similar. Required
Description This should give a brief description about what your test is about. For example The mobile blog page. Optional
Live URL This should be a fully qualified url for your current page that is in production, or on your staging environment. This is the base for the visual comparison. Visual comparisons work best for static pages, therefore it may be a good idea to create a kitchen sink page that will store your components in a static state. Required
Dev URL This should be a fully qualified url for your page that is under development. For instance this could point to your local page on localhost. Required
Browser Size The browser width that you'd like to run the test at. If you're developing a mobile page then you can set this to a mobile browser width and the test will run at that size. Optional

Once the test has been created you can access the test page and select the Run Test button to begin the test, once concluded the page will refresh and you'll be able to see the comparisons. Once the comparisons are available you can click on the dev page screenshot to toggle the overlay which will highlight the changes.

You can re-run the test as many times as you like. If there's an error with the test, such as one of the paths being unavailable, the interface will alert you that there was a problem. From the test page you're also able to edit and remove the test if you've made a mistake or if you no longer have a need for it.

API ๐Ÿ“ก

There are several API endpoints which can be utilized if you'd prefer to not use the interface. Screenshots get saved by default in the ./client/public/diff directory.

Endpoint Type Description
/tests GET Fetches all tests, returns an array.
/tests POST Adds a test, accepts a JSON object with the properties name, description, live, dev, and size.
/tests/:id GET Fetches a specific test based on its id.
/tests/:id PUT Updates a specific test, accepts a JSON object with the properties name, description, live, dev and size.
/tests/:id DELETE Deletes a specific test.
/run GET Runs all tests that are stored in the database. Eventually returns an array containing all of the tests with a success flag that will either be true or false depending on if the test resulted in an error or not.
/run/:id GET Runs a specific test. Returns the test object with a success flag that will be either true or false depending on if the test resulted in an error or not.

You can find an example response from the API below.

[
    {
        "_id": "5b5359913a6b910586b1345b",
        "name": "Blog Page",
        "description": "My Blog Page",
        "live": "https://jamesiv.es/blog",
        "dev": "http://localhost:4000/blog",
        "size": 728
    }
]

Screenshot

front-end-visual-comparison-tool's People

Contributors

dependabot-support avatar dependabot[bot] avatar dwolfand avatar jamesives avatar rohitrajendran avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

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.