How to use the unexpected.addAssertion 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 Anifacted / lerna-update-wizard / test / git.spec.js View on Github external
const { default: runProgram } = require("./utils/runProgram");
const generateProject = require("./utils/generateProject");
const expect = require("unexpected");
const util = require("util");
const exec = util.promisify(require("child_process").exec);
const chalk = require("chalk");

expect.addAssertion(
  " when run ",
  async (expect, cmd, assertion, compare) => {
    const result = await exec(cmd);
    return result.stderr
      ? expect.fail(new Error(`Command errored: ${result.sdterr}`))
      : expect(result.stdout.trim(), assertion, compare);
  }
);

describe("Git features", async () => {
  it("correctly adds git commit and branch", async () => {
    // eslint-disable-next-line
    jest.setTimeout(100000);
    const projectPath = await generateProject({
      name: "project-a",
      git: true,
github mickhansen / dataloader-sequelize / resources / mocha-bootload.js View on Github external
name: 'Sequelize.Association',
  identify: function (value) {
    return value && value instanceof Sequelize.Association;
  },
  inspect: function (value, depth, output) {
    output
      .text(value.associationType).text(': ')
      .text(value.source.name).text(' -> ').text(value.target.name)
      .text('(').text(value.as).text(')');
  },
  equal: function (a, b, equal) {
    return a.associationType === b.associationType && equal(a.source, b.source) && equal(a.target, b.target) && a.as === b.as;
  }
});

unexpected.addAssertion(' [not] to be shimmed', function (expect, subject) {
  return expect(subject, '[not] to have property', '__wrapped');
});

unexpected

Extensible BDD assertion toolkit

MIT
Latest version published 1 year ago

Package Health Score

60 / 100
Full package analysis