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

phantomjs-test-starter

v1.0.0

Published

Starter Template for testing PhantomJS ‘Applications’ with Jasmine, Grunt, and Istanbul

Downloads

7

Readme

phantomjs-test-starter

A boilerplate / starter template for testing PhantomJS ‘Applications’ with Jasmine, Grunt and Istanbul.

There are many resources on how to run tests in PhantomJS, but none on testing Applications written in PhantomJS itself. Non-Trivial Applications such as Data Mining Web Crawlers or Web Page Automation Tools for example.

Conceptually I find it helps to think of PhantomJS as having a server-side and a client-side. The client-side is what happens over in a remote page (inside calls to WebPage.evaluate etc) and the server side is everything else.

This project is concerned with how you test the so-called server side of a PhantomJS Application.

Installation

NPM

npm install phantomjs-test-starter

Git

git clone [email protected]:JamieMason/phantomjs-test-starter.git
cd phantomjs-test-starter
npm install

Global dependencies

Local dependencies are installed by npm install but you will also need $ phantomjs (of course) and npm install -g grunt-cli.

Running tests

Running grunt test will run the tests and generate a coverage report at ./spec/build/reports/index.html.

Writing tests

By optional convention, tests are located at ./spec/unit/ at the same relative path as the file being tested.

For example, tests for the following files:

  • ./src/modules/network/ajax.js
  • ./src/modules/events.js
  • ./src/modules/data/local-storage.js

Would be located at:

  • ./spec/unit/modules/network/ajax.test.js
  • ./spec/unit/modules/events.test.js
  • ./spec/unit/modules/data/local-storage.test.js

Adding new tests

All test files added to ./spec/unit/unit.runner.js will run, (I hope to generate this file to avoid this manual step).

Modified Jasmine 1.3.1

A slightly modified version of jasmine-standalone-1.3.1 is needed as that does not run in PhantomJS (outside of a page.evaluate that is, which is not relevant to our use case).

This is due to a perfectly reasonable assumption that any JavaScript environment will have either module.exports or window and not both — which is the case in PhantomJS.

The core Jasmine library is identical, only how it's exposed has been modified.

.gitignore

They've been left unignored for this example so can see what gets generated during tests, but in a real application you will want to ignore:

  • coverage-reporter.json
  • spec/build

Contributing

Please fork and pull request or raise an issue if you can help improve this resource in any way.