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 🙏

© 2024 – Pkg Stats / Ryan Hefner

grunt-mocha-slimer

v0.0.2

Published

Grunt plugin runs Mocha tests in a (nearly) headless Mozilla Firefox browser-engine via SlimerJS

Downloads

10

Readme

grunt-mocha-slimer

Grunt plugin to run Mocha tests in a (nearly) headless Mozilla Firefox browser-engine via SlimerJS

Build Status NPM version Dependency Status devDependency Status

Run your Mocha browser tests in SlimerJS's npm wrapper with all the regular reporters.

Some internal parts sourced from grunt-mocha by @kmiyashiro.

:warning: Very early version, user beware.

Known issues

  • no error messages in async errors
  • stack traces missing
  • needs a lot more real-world use
  • needs write-to-file support for some reporters

Getting Started

This plugin requires Grunt ~0.4.1

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

$ npm install grunt-mocha-slimer --save-dev

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('grunt-mocha-slimer');

The "grunt-mocha-slimer" task

For an example html see the ./test folder.

Basic options

grunt.initConfig({
	mocha_slimerjs: {
		all: {
			options: {
				ui: 'bdd'
				reporter: 'Spec'
				run: true,
			},
			src: ['test/index.html']
		}
	}
});

Advanced options

grunt.initConfig({
	mocha_slimerjs: {
		all: {
			options: {
				ui: 'bdd'
				reporter: 'Spec'
				grep: 'some keyword'
				// SlimerJS timeout
				timeout: 10000,
				// set to false and call it later for async tests (AMD etc)
				run: false,
				// run SlimerJS via 'xvfb-run': for true headless testing
				// must be true on Travis-CI, use: (process.env.TRAVIS === 'true')
				xvfb: true,
				// pass http urls (use grunt-contrib-connect etc)
				urls: ['http://localhost:8080/test/index.html']
			}
		}
	}
});

Better docs at a later date.

Why not a PhantomJS based grunt + mocha?

  • SlimerJS uses Firefox/XulRunner (Gecko) so it's something different PhantomJS' Webkit (V8).
  • PhantomJS uses an ancient Webkit version that is missing some modern features, like Uint8ClampedArray, Float64Array etc. You need this to test interesting canvas libraries on a generic node.js based CI like Travis.
  • SlimerJS could enable supports addons and user-profiles (let me know if there is a use-case).
  • grunt-mocha-slimer seems slightly faster then grunt-mocha as all tests are in one process (not sure why grunt-mocha doesn't do that, we'll see).
  • This modules streams test- and log data over SlimerJS' stdout for snappy feedback.

Why the flashing windows?

This is the nature of SlimerJS and the engine it runs, as . On Linux and OSX SlimerJS has support for xvfb if you have it installed. For more info see the SlimerJS documentantion.

You can enable this by setting xvfb: true (you need this for Travis-CI, see below).

Is this ready to use?

Wisdom says no, adventure and necessity say.. give it a try. It is the simplest way to do all the mocha-flavoured things you cannot do in PhantomJS's crappy archaic Webkit.

I needed it for some OSS projects and it seems to work (well, at least it properly fails if assertions fail).

Future

Probably

  • loot some more features from grunt-mocha
    • growl support
    • output-to-file (for XUnit etc)
  • support more SlimerJS commandline parameters?
    • user profile handling?
    • proxy support?
  • extract mocha/slimer runner to own module

Maybe

  • expose screenshot feature?
  • expose a file-io stream (to dump debug data to disk)?
  • auto-inject mocha JS & CSS?
  • support direct JS tests without html?
  • auto-enable xvfb on known CI's?

Out-of-scope:

  • WebDriver support (use CasperJS)

History

  • 0.0.x - Early releases.

Contributing

Contributions are very welcome, please create an Issue before doing something major.

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.

License

Copyright (c) 2014 Bart van der Schoor

Licensed under the MIT license.

Various snippets copy/hacked from grunt-mocha by Kelly Miyashiro.