Skip to content
This repository was archived by the owner on Jul 14, 2019. It is now read-only.

jhaynie/example-vue-jsdom-canvas

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Example Project for Vue.js + JSDOM + webpack + Mocha + Canvas with image diffing

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published