Skip to content

Commit

Permalink
Add HTML validation for Nunjucks page template
Browse files Browse the repository at this point in the history
  • Loading branch information
colinrotherham committed Nov 2, 2023
1 parent 5529af2 commit 1ebf862
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions packages/govuk-frontend/src/govuk/template.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const crypto = require('crypto')

require('html-validate/jest')

const { renderTemplate } = require('@govuk-frontend/helpers/nunjucks')
const { nunjucksEnv } = require('@govuk-frontend/lib/components')

Expand Down Expand Up @@ -53,6 +55,16 @@ describe('Template', () => {

expect($('html').hasClass('my-custom-class')).toBeTruthy()
})

it('renders valid HTML', () => {
expect(renderTemplate('govuk/template.njk').html()).toHTMLValidate({
extends: ['html-validate:document'],
rules: {
// Allow optional subresource integrity (SRI)
'require-sri': 'off'
}
})
})
})

describe('<head>', () => {
Expand Down

0 comments on commit 1ebf862

Please sign in to comment.