Giter Club home page Giter Club logo

example-vue-jsdom-canvas's Introduction

Using JSDOM + webpack + Mocha + Vue.js + Canvas

This is a continuation of the previous example which expands unit testing to add support for unit testing images rendered from a (all server side).

You should read the README for this project for more background on how to setup the project and details behind it.

Usage

npm install (or yarn install)
npm test

You should be able to install your dependencies and then run an example test case using Mocha.

Explanation of what's happening

This example project adds basic Mocha + webpack + JSDOM + Vue.js testing of server side Vue components but adds the ability to test canvas / image based rendered components and image diffing.

The Vue component basically renders the following to an HTML canvas:

The image diffing is performed with the node library image-diff.

This also provides a basic example of how you can server-side render canvas or image based UI component. This could be useful for sending HTML based emails that are dynamically generated, etc.

See the example test case to understand the logic at src/test/test.js.

NOTE: a slightly modifying test command than the previous project. This project uses a custom register file to opt-in image loading from the JSDOM which is by default off.

Author

Jeff Haynie @jhaynie

License

MIT. Pull requests encouraged and welcome.

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.