Skip to content

Commit

Permalink
test: configure cypress to use cypress-log-to-output
Browse files Browse the repository at this point in the history
  • Loading branch information
grisha87 committed Dec 16, 2023
1 parent 5f4523a commit 2074a21
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 5 deletions.
31 changes: 26 additions & 5 deletions examples/web/image.html
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ <h3>Logs</h3>
li.appendChild(document.createTextNode(msg));
logs_el.appendChild(li);
}

function setResponse(result) {
if (urlObject) {
URL.revokeObjectURL(urlObject);
Expand All @@ -99,11 +100,31 @@ <h3>Logs</h3>
}

const logger = {
log: (msg) => appendLog(`[${new Date().toISOString()}] ${msg}`),
warn: (msg) => appendLog(`[${new Date().toISOString()}] [warn] ${msg}`),
debug: (msg) => appendLog(`[${new Date().toISOString()}] [debug] ${msg}`),
error: (msg) => appendLog(`[${new Date().toISOString()}] [error] ${msg}`),
info: (msg) => appendLog(`[${new Date().toISOString()}] [info] ${msg}`),
log: (msg) => {
const fullMsg = `[${new Date().toISOString()}] ${msg}`;
console.log(fullMsg);
appendLog(fullMsg);
},
warn: (msg) => {
const fullMsg = `[${new Date().toISOString()}] [warn] ${msg}`;
console.warn(fullMsg);
appendLog(fullMsg);
},
debug: (msg) => {
const fullMsg = `[${new Date().toISOString()}] [debug] ${msg}`;
console.debug(fullMsg);
appendLog(fullMsg);
},
error: (msg) => {
const fullMsg = `[${new Date().toISOString()}] [error] ${msg}`;
console.error(fullMsg);
appendLog(fullMsg);
},
info: (msg) => {
const fullMsg = `[${new Date().toISOString()}] [info] ${msg}`;
console.log(fullMsg);
appendLog(fullMsg);
},
};

async function run() {
Expand Down
6 changes: 6 additions & 0 deletions tests/cypress/plugins/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default (on, config) => {
/** the rest of your plugins... **/
require("cypress-log-to-output").install(on);
// or, if there is already a before:browser:launch handler, use .browserLaunchHandler inside of it
// @see https://github.com/flotwig/cypress-log-to-output/issues/5
};

0 comments on commit 2074a21

Please sign in to comment.