Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
}
// 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);
}
}
}
};
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);
}