cypress-smart-logs
Cypress plugin allowing to add additional information to logs and configure the output.
Setup plugin
Change your cypress/plugins/index.ts
import smartLogs = require("cypress-smart-logs/plugin");
module.exports = (on: Cypress.PluginEvents, config: Cypress.ConfigOptions) => {
smartLogs.install(on, config);
};
Register commands
Change your cypress/support/index.ts
import "cypress-smart-logs/commands";
Cypress.SmartLogs.setLogType("WARNING", {
format: "*",
target: { openMode: ["file", "window"], runMode: ["file"] },
pairedCommands: ["custom"],
});
Cypress.Commands.add("custom", () => {
Cypress.log({});
});
and add type defs to cypress/support/index.d.ts
declare namespace Cypress {
interface ILogTypes {
WARNING: ILogTypeConfig;
}
interface Chainable<Subject> {
custom(): Cypress.Chainable<void>;
}
}
Additional settings
Logs are by default saved only for failed cases. In run mode are window logs disabled.
Additional configuration can be defined in Cypress.SmartLogs.Config object.