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

remix-jasmine-setup

v0.0.7

Published

[![NPM version](https://badge.fury.io/js/remix-jasmine-setup.svg)](http://badge.fury.io/js/remix-jasmine-setup) [![peerDependencies Status](https://david-dm.org/remix/remix-jasmine-setup/peer-status.svg)](https://david-dm.org/remix/remix-jasmine-setup?typ

Downloads

5

Readme

Remix's Jasmine setup

NPM version peerDependencies Status devDependencies Status Open Source Love

This is an opinionated setup for Jasmine, developed at Remix.

Usage

Include this module at the top of your tests entry point (e.g. tests.js):

import 'remix-jasmine-setup';

Be sure that at this point jasmine and jasmine-ajax have been loaded.

You can also use the compiled index.js in a <script> tag.

IMPORTANT: Make sure that this setup is included before any polyfills! Otherwise those polyfills may not get the stubbed handles to things like window.setTimeout. You might need to change your Babel setup to not include polyfills at compile-time, but instead include them manually after loading this setup.

Promise libraries can be especially tricky, as some of them use sophisticated methods to get really fast asynchronous behaviour. But this setup tries to avoid any asynchronous behaviour in tests, so it needs a Promise library that just uses window.setTimeout or so. We currently recommend using promise-polyfill.

Features

We set up Jasmine to do a bunch of things:

  • Prevent tests depending on each other, or leaking state, by:
    • randomizing test order;
    • flushing the clock after each test, and making sure nothing else executes;
    • ensuring the number of DOM elements before and after each test are the same.
  • Properly removing all sources of asynchronicity, by:
    • installing jasmine.clock() and jasmine.Ajax();
    • overwriting Promises and functions like requestAnimationFrame to use jasmine.clock();
    • making sure no Ajax requests are fired after a test runs.
  • Tightening when tests fail, by:
    • catching errors that Jasmine doesn't catch by setting a global window.onerror handler;
    • failing a test when anything prints to the console while the test runs, to catch warnings raised by libraries.
  • Finally, we add an assortment of minor niceties:
    • Reducing the pretty print depth, to avoid locking up the browser in certain cases.
    • Logging the seed used for the random order, which is useful for debugging flakey tests in CI.
    • Making the window scrollable, even if there's CSS that prevents that.
    • Allowing setting ?loadConsoleReporter=true, which prints when each test started and ended executing, which is useful for tracking down problems.
    • Adding beforeTestCallbacks and afterTestCallbacks arrays that can be used in application code to add some global state cleanup or assertions, and having them guaranteed to be called at the right times (as opposed to beforeEach/afterEach, which may be called too early or too late).

Future

  • Allow configuration of features.
    • Turning them on and off individually.
    • Making exceptions, e.g. to not being able to log to the console.
  • Merge some of these improvements into Jasmine itself (some might already be there, we'd have to check).
  • Better interoperability with polyfills.

License

MIT