Skip to content

Commit

Permalink
fix: restore prior DOM after automatic check jest (#609)
Browse files Browse the repository at this point in the history
  • Loading branch information
navateja-alagam authored Nov 8, 2023
1 parent 216fd94 commit b444195
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/jest/src/automatic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export async function automaticCheck(opts: AutoCheckOpts = defaultAutoCheckOpts)
}

const violations: AxeResults = [];
const currentDocumentHtml = document.body.innerHTML;
if (originalDocumentBodyHtml) {
document.body.innerHTML = originalDocumentBodyHtml;
}
Expand All @@ -95,6 +96,7 @@ export async function automaticCheck(opts: AutoCheckOpts = defaultAutoCheckOpts)
}
} finally {
setOriginalDocumentBodyHtml(null);
document.body.innerHTML = currentDocumentHtml;
if (opts.cleanupAfterEach) document.body.innerHTML = ''; // remove non-element nodes
// TODO (spike): Disable stack trace for automatic checks.
// Will this affect all errors globally?
Expand Down

0 comments on commit b444195

Please sign in to comment.