npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

spritesmith-engine-test

v5.1.1

Published

Common test suite for spritesmith engines

Readme

spritesmith-engine-test Build Status

Common test suite for spritesmith engines

These files were written for usage with mocha

Specification version

The current repository version is built to match specification version:

2.0.0

Specification documentation can be found at:

https://github.com/twolfson/spritesmith-engine-spec/tree/2.0.0

Getting started

Install the module via: npm install spritesmith-engine-test

Create files that require and run the test suite:

test/myengine_test.js:

// Load in dependencies
var spritesmithEngineTest = require('spritesmith-engine-test');
var MyEngine = require('../lib/engine');

// Run our test suite
// DEV: This loads and define multiple `mocha` test suites
spritesmithEngineTest.run({
  engine: MyEngine,
  engineName: 'myengine'
});

Run your tests via mocha:

# Install test dependencies
npm install mocha

# Run mocha test suite
./node_modules/.bin/mocha test/
#  myengine
#    interpretting an image file
#      ✓ gathers statistics on an image file
#  ...

Documentation

spritesmith-engine-test exports the following keys its module.exports:

  • config Object - Assortment of configurations used for each test suite
    • See lib/config.js for documentation
    • Feel free to reuse these in any of your one-off tests
  • run Function - Test suite runner
    • Documentation cane be found below
  • spritesmithUtils Object - One-off utilities for our test mocha suites
    • See lib/utils/ for documentation
    • Feel free to reuse these in any of your one-off tests

run(params)

Generates a set of mocha test suites for a spritesmith engine

  • params Object - Container for test setup
    • engine Object - spritesmith engine as defined by spritesmith-engine-spec
    • engineName String - Name of engine to use in test suites
    • engineOptions Object - Optional options to pass to engine constructor
    • tests Object - Optional overrides to enable/disable tests
      • By default, all tests will run
      • Signature should be testName: boolean (e.g. {interpretPngImage: false})
      • A list of tests can be found below

Example with tests:

spritesmithEngineTest.run({
  engine: myengine,
  engineName: 'myengine',
  // Skip over rendering a GIF image
  tests: {
    renderGifCanvas: false
  }
});

Tests

Our test suite has the following tests built into it:

  • assertSpecVersion - Verify the engine has a specVersion for the corresponding specification
  • interpretPngImage - Loads a PNG image and asserts we get the correct height/width
  • interpretJpegImage - Same as interpretPngImage but for a JPEG (using format: 'jpeg')
  • interpretJpgImage - Same as interpretPngImage but for a JPEG (using format: 'jpg')
  • interpretGifImage - Same as interpretPngImage but for a GIF
  • renderPngCanvas - Loads a PNG image, renders it via the export, and asserts the image is more/less the same
  • renderJpgCanvas - Same as renderPngCanvas but for a JPG
  • renderGifCanvas - Same as renderPngCanvas but for a GIF
  • renderPngBufferVinylCanvas - Same as renderPngCanvas but uses a buffer-based Vinyl object instead of a filepath
  • renderPngStreamVinylCanvas - Same as renderPngCanvas but uses a stream-based Vinyl object instead of a filepath
  • renderPngNullVinylCanvas - Same as renderPngCanvas but uses a null-based Vinyl object instead of a filepath
  • renderMultiplePngImages - Load multiple images, place them at different spots on a canvas, and verify the placements are respected
  • renderManyPngImages - Load 500 images and render them on a canvas
    • This is to verify each engine can handle a signficant amount of images
  • interpretLargePngImage - Load an 800x600 image and assert we get the correct height/width
    • This is part of a regression we encountered in phantomjssmith

Donating

Support this project and others by twolfson via donations.

http://twolfson.com/support-me

License

Copyright (c) 2013-2014 Todd Wolfson

Licensed under the MIT license.