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

gofur

v1.1.1

Published

Easily run your mocha JS tests in the browser

Downloads

39

Readme

gofur

Circle CI Greenkeeper badge

Easily run your mocha JS tests in the browser. Gofur allows you to focus on writing tests and not on the details of how to run your tests.

Set up

$ npm install gofur --save-dev

If you wish to view the code coverage report then you should also install istanbul

$ npm install istanbul --save-dev

Command line parameters

-c cache            The path to a directory that will be used to store temporary
                    files, including code coverage reports. You should probably
                    make sure that the contents of this directory are ignored
                    with a .gitignore file
-t test-file        The entry point for your mocha tests
-p port             The port for running the test HTTP server, defaulted to 8001
-b browser          A colon-separated list of
                    `(saucelabs|selenium):browserName:browserVerion:platform`
-s path-to-script   Optional path to a script that will be run before the browser
                    tests. This script will then be killed after the tests. This
                    script can be used to set up fixtures.

Run tests in headless browser and generate code coverage

Note: you must have Chrome installed

$ node_modules/gofur/scripts/browser-coverage/test.js -c cache -t test/index.js
$ node_modules/istanbul/lib/cli.js report --dir cache/coverage/browser --root cache/coverage/browser lcov
You can then open coverage/browser/lcov-report/index.html in any browser to view the code coverage report

You can then enforce a certain level of code coverage, e.g.

$ node_modules/istanbul/lib/cli.js check-coverage --lines 100 --function 100 --statements 100 --branches 100 cache/coverage/browser/coverage.json

You can also filter the tests, e.g.

$ node_modules/gofur/scripts/browser-coverage/test.js -c cache -t test/index.js -g reg-ex

Manually run tests in a browser

$ node_modules/gofur/scripts/browser-coverage/serve.js -c cache -t test/index.js
Use any browser to visit http://127.0.0.1:8001/index.html
And you can filter the tests, e.g. http://127.0.0.1:8001/index.html?grep=reg-ex

Run tests in a browser without generating code coverage

Headless with Chrome (you must have Chrome installed):

$ node_modules/gofur/scripts/browser/test.js -c cache -t test/index.js

You can also filter the tests, e.g.

$ node_modules/gofur/scripts/browser/test.js -c cache -t test/index.js -g reg-ex

Chrome:

$ node_modules/gofur/scripts/browser/test.js -c cache -t test/index.js -b selenium:chrome

Firefox:

Note: you must have Firefox installed

$ node_modules/gofur/scripts/browser/test.js -c cache -t test/index.js -b selenium:firefox

Example

See js-seed for a complete working example

TODO: Run Saucelabs Tests In a Specific Browser

Notes

As per https://github.com/domenic/chai-as-promised/releases/tag/v7.0.0, chai-as-promised 7 isn't supported by PhantomJS 2.1.14. Hopefully a later version of PhantomJS will support it or we'll need to transpile chais-as-promised

Misc

A hacky way to debug the browser tests is to use print statements in the form window.results.failures.push({ title: 'my msg' });