Cypress plugin

To validate browser source from cypress:

npm install --save-dev cypress-html-validate

See cypress-html-validate for details.

Usage

In cypress/plugins/index.js:

const htmlvalidate = require("cypress-html-validate/dist/plugin");

module.exports = (on) => {
  htmlvalidate.install(on);
};

cypress/support/index.js:

import "cypress-html-validate/dist/commands";

In specs:

it("should be valid", () => {
  cy.visit("/my-page.html");
  cy.htmlvalidate();
});

Configuration

html-validate configuration can be passed in cypress/plugins/index.js:

htmlvalidate.install(on, {
  rules: {
    foo: "error",
  },
});