Skip to content

Commit

Permalink
Run HTML validation with id="content" wrapper
Browse files Browse the repository at this point in the history
We previously enabled the rule `no-missing-references` but lots of examples target `id="content"` on the preview container which isn’t available when only the component is rendered

For example from fieldset.yaml

```
  - name: with describedBy
    hidden: true
    options:
      describedBy: content
      legend:
        text: Which option?
```
  • Loading branch information
colinrotherham committed Nov 2, 2023
1 parent db22160 commit e2311a8
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const {
} = require('@govuk-frontend/lib/components')
const validatorConfig = require('govuk-frontend/.htmlvalidate.js')
const { HtmlValidate } = require('html-validate')
const { outdent } = require('outdent')

describe('Components', () => {
let nunjucksEnvCustom
Expand Down Expand Up @@ -65,10 +66,14 @@ describe('Components', () => {
// Validate component examples
for (const { component: componentName, fixtures } of componentsFixtures) {
const fixtureTasks = fixtures.map(async (fixture) => {
const html = render(componentName, {
context: fixture.options,
fixture
})
const html = outdent`
<div id="content" class="govuk-width-container">
${render(componentName, {
context: fixture.options,
fixture
})}
</div>
`

// Validate HTML
return expect({
Expand Down

0 comments on commit e2311a8

Please sign in to comment.