How to use the zombie.Assert function in zombie

To help you get started, we’ve selected a few zombie 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 TheFive / osmbc / test / testutil.js View on Github external
}
  }
  // there is a difference, so create the actual data as file
  // do easier fix the test.
  fs.writeFileSync(actualFile, string, "UTF8");
  if (stopOnError) {
    should(string).eql(expected, "HTML File " + name + " is different.");
  } else {
    if (string !== expected) {
      errorList.push("HTML File " + name + " is different.");
    }
  }
};


Browser.Assert.prototype.expectHtml = function expectHtml(givenPath, name, cb) {
  console.warn("Browser.Assert.prototype.expectHtml is deprecated");

  if (typeof name === "function") {
    cb = name;
    name = givenPath;
    givenPath = "screens";
  }
  let expected = "not read yet";
  let expectedFile = path.join(__dirname, givenPath, name + ".html");
  let actualFile   = path.join(__dirname, givenPath, name + "_actual.html");
  let string = this.html();
  try {
    expected = fs.readFileSync(expectedFile, "UTF8");
  } catch (err) {
    console.error(err);
  }
github TheFive / osmbc / test / testutil.js View on Github external
}
  }
};
exports.nockHtmlPagesClear = function nockHtmlPagesClear() {
  nock.cleanAll();
};

Browser.prototype.keyUp = function(targetSelector, keyCode) {
  let event = this.window.document.createEvent("HTMLEvents");
  event.initEvent("keyup", true, true);
  event.which = keyCode;
  let target = this.window.document.querySelector(targetSelector);
  if (target) target.dispatchEvent(event);
};

Browser.Assert.prototype.expectHtmlSync = function expectHtmlSync(errorList, givenPath, name) {
  let stopOnError = false;
  if (!Array.isArray(errorList)) {
    stopOnError = true;
    name = givenPath;
    givenPath = errorList;
    errorList = undefined;
  }
  let expected = "not read yet";
  let expectedFile = path.join(__dirname, givenPath, name + ".html");
  let actualFile   = path.join(__dirname, givenPath, name + "_actual.html");
  let string = this.browser.html();
  try {
    expected = fs.readFileSync(expectedFile, "UTF8");
  } catch (err) {
    console.error(err);
  }

zombie

Insanely fast, full-stack, headless browser testing using Node.js

MIT
Latest version published 6 years ago

Package Health Score

56 / 100
Full package analysis