gonzalocordero / vnu-jest

A VNU jest plugin

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

vnu-jest

Simple jest plugin to run HTML validation tests.

Usage

import { validateHTML, toContainCorrectMarkUp } from'vnu-jest';

describe('vnu-cli', () => {
    it('should validate correct valid markup', async () => {
        const html = '<p><span></span></p>';
        expect.extend(toContainCorrectMarkUp);
        
        try {
            expect(await validateHTML(html)).toContainCorrectMarkUp();
        } catch (error) {
            throw error;
        }
    });

    it('should fail with incorrect markup', async () => {
        const html = '<span><p></p></span>';
        expect.extend(toContainCorrectMarkUp);

        try {
            expect(await validateHTML(html)).toContainCorrectMarkUp();
        } catch (error) {
            throw error;
        }
    });
});

About

A VNU jest plugin

License:MIT License


Languages

Language:JavaScript 100.0%