How to use the unexpected.installPlugin function in unexpected

To help you get started, we’ve selected a few unexpected examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Lugribossk / simple-dashboard / test / testSetup.js View on Github external
/*global global*/
import jsdom from "jsdom";
import expect from "unexpected";
import unexpectedSinon from "unexpected-sinon";
import sinon from "sinon";

// Set up expected browser globals.
global.document = jsdom.jsdom("");
global.window = document.defaultView;
global.navigator = {
    userAgent: ""
};

// Set up Unexpected plugins (on the actual unexpected instance, so they show up when it is imported by other modules).
expect.installPlugin(unexpectedSinon);

// Automatically restore Sinon stubs after tests end.
var oldWrap = sinon.wrapMethod;
var wrappeds = [];
var afterSetup = false;
sinon.wrapMethod = function (...args) {
    var out = oldWrap.apply(sinon, args);
    wrappeds.push(out);
    if (!afterSetup) {
        // Delay setting up afterEach since it is not yet defined when this module is run.
        afterEach(() => {
            wrappeds.forEach(wrapped => {
                wrapped.restore();
            });
            wrappeds = [];
        });

unexpected

Extensible BDD assertion toolkit

MIT
Latest version published 9 months ago

Package Health Score

67 / 100
Full package analysis