Open spschlegel opened 3 years ago
How can we retrieve the recorded logs. Is it possible to store these logs in a file? If yes how can this be done?
From the Readme: The logs will be stored in an internal buffer. They can be accessed using the getLogs exported function. The buffer can be cleared using the clearLogs exported function.
So we used the getLogs
function to retrieve the logs and then wrote them to a file using fs.createWriteStream
Do you have any code sample for this? I tried using getLogs, but didn't get it.
Something like this:
import {
getLogs
} from 'cypress-log-to-output';
const logs = getLogs();
Something like this:
import { getLogs } from 'cypress-log-to-output'; const logs = getLogs();
May be stupid question, but how use this in test step?
Something like this:
import { getLogs } from 'cypress-log-to-output'; const logs = getLogs();
May be stupid question, but how use this in test step?
I'm also interested about how to use it in a test step.
I don't think I really understand what you want to do.
Using this is not tied to tests in general.
You import the getLogs
function and then you call it whenever you want to retrieve the current logs.
You will get them as an array and then it's up to you to do something with that array.
I don't think I really understand what you want to do. Using this is not tied to tests in general. You import the
getLogs
function and then you call it whenever you want to retrieve the current logs.
Then test crashed, and cypress-log-to-output - breaks other packages, such as cypress-audit. I had to remove it altogether so that the rest of the packages would work again.
Something like this:
import { getLogs } from 'cypress-log-to-output'; const logs = getLogs();
May be stupid question, but how use this in test step?
The plugin and your spec file run in different environments, to access the node process from your test spec you need to use cy.task.
When installing the plugin, add:
import { getLogs, install } from 'cypress-log-to-output';
module.exports = (on, config) => {
/** the rest of your plugins... **/
const options = { recordLogs: true };
install(on, filterCallback, options);
on('task', {
getDebuggerLogs(){
return getLogs();
}
});
}
Then on your spec file access it:
cy.task('getDebuggerLogs').then((logs) => {
// do whatever with the logs here
}
Its great being able to record the console logs in addition to printing them to the terminal. I would like to store the logs during the cypress tests for our CI builds but printing them to the terminal output as well is flooding the output. Is there a way to only record the logs and not print them to the terminal output?