When using htmlvalidate with cypress (version 9 or less) you can simply install via cypress/plugins/index.js::
const htmlvalidate = require("cypress-html-validate/dist/plugin");
module.exports = (on) => {
htmlvalidate.install(on);
};
However plugins was depreciated in cypress version 10 and you need to use config.
However it's not clear to me how to enable htmlvalidator in this manner. E.g:
const {defineConfig} = require('cypress');
const {htmlvalidate} = require("cypress-html-validate/dist/plugin");
module.exports = defineConfig({
projectId: '4dofbo',
e2e: {
setupNodeEvents(on, config) {
on('task', {
// WHAT GOES HERE?
});
},
},
});
You don't need to utilize any on('task') function, and instead can use the function in setupNodeEvents.
Directly from the cypress-html-validate documentation
export default defineConfig({
e2e: {
setupNodeEvents(on) {
htmlvalidate.install(on);
},
},
});