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 🙏

© 2026 – Pkg Stats / Ryan Hefner

fusion-js-test-common

v1.0.0

Published

Local reimplementation of the shared AMD/RequireJS + Karma + QUnit test harness

Readme

fusion-js-test-common

A local test harness package providing shared Karma, QUnit, and RequireJS tooling that the frontend test suite is written against.

What it provides

  • karma / commonConfiguration (require('fusion-js-test-common')) — the two things etc/frontend/karma.conf.js and gulpfile.js import. commonConfiguration(config) takes the config.src.main/config.src.test dirs+file patterns karma.conf.js already builds and wires up everything else: a RequireJS bootstrap, the qunit karma framework, a ChromeHeadlessNoSandbox launcher, and client.qunit.testTimeout.
  • AMD modules, resolved via RequireJS in the browser (see browser/): fusion/test/qunit, fusion/test/hamjest, fusion/test/jquery, fusion/test/backbone, fusion/test/mock-declaration, fusion/test/mock-view, fusion/test/mock-dialog2.
  • ajs-stub.js / sinon-compat.js — plain (non-AMD) scripts loaded before RequireJS: a harmless stand-in AJS global + empty dvcs.connector.plugin.soy namespace (main/js reaches for both directly, not through AMD), and a compatibility shim for the two sinon APIs this suite uses that modern sinon removed (see below).

How the test API works

QUnit.module('some/module/id', {
    require: { main: 'some/module/id' },          // 'main' → 2nd arg of test()/beforeEach()
    mocks: {
        dep: QUnit.moduleMock('some/dep', () => value),               // plain factory
        other: QUnit.moduleMock('some/other', new MockDeclaration([    // sinon-stub-backed
            'methodName', 'nested.methodName'
        ]).withConstructor())                       // .withConstructor() if `new`'d
    },
    templates: { 'some.global.path': stubFn },      // set before main is required
    beforeEach(assert, Main, mocks) { ... },
    afterEach(assert, mocks) { ... },
    someHelper() { ... }                            // mixed onto `this` for tests to call
});

QUnit.test('description', function (assert, Main, mocks) {
    assert.assertThat('message', actual, matcher);   // fusion/test/hamjest bridge
});

Every entry in mocks is registered as a global RequireJS module (requirejs.undef(id); define(id, [], () => value)) before require.main is resolved, so anything main's dependency graph pulls in under that id gets the mock instead of the real file. Mocks + main are resolved once per QUnit.module() call (in a before hook) and reused for every test() in that module — this suite adds/removes sinon spies on the same shared mock objects across tests rather than re-creating them each time.

Between tests, fusion/test/qunit automatically:

  • calls .reset() on every sinon.stub() a MockDeclaration created (and on a fusion/test/mock-view-based answer object, which also gets its event listeners cleared via .off()) — tests configure .returns(...) etc. fresh per test and rely on that not leaking into the next one;
  • restores a plain-object factory mock (e.g. a fake window) to a snapshot taken when it was first created — some tests mutate mocks.window.location directly.

After a module's last test, every app id it touched (via mocks or require) is requirejs.undef()'d, so a module mocked as a dependency in one file (e.g. dvcs-repos-table-view) doesn't leak into another file where it's the main under test. jquery/underscore/backbone/sinon/ fusion/test/* are exempt from that cleanup — undefining those would force RequireJS to re-fetch and re-evaluate the real UMD script, minting a new jQuery/Backbone constructor with its own disconnected .fn/prototype.

Compatibility notes

  • jQuery is pinned to 1.12.4, not a modern 3.x/4.x release: jQuery 3.0 removed the deprecated jqXHR.error()/.success()/.complete() shortcuts this suite's REST client tests use.
  • sinon is modern (18.x), not vendored at an old version, so sinon-compat.js shims the two APIs this suite relies on that were removed: spy/stub.reset() (split into resetHistory()/resetBehavior()) and the legacy sinon.stub(obj, 'method', fn) 3-arg form (now sinon.stub(obj, 'method').callsFake(fn)).
  • Karma runs on ChromeHeadlessNoSandbox, not PhantomJS: the karma.conf.js browsers entry was updated for this. PhantomJS is unmaintained and, more concretely, the raw ES2015 in test/src/**/*-test.js (const, arrow functions, template literals) isn't valid PhantomJS-era JS — Karma serves those files directly (no transpile step), so a modern JS engine is required regardless of PhantomJS's maintenance status.