Skip to content

Commit

Permalink
fix: Inject Percy CSS before very last closing body tag (#454)
Browse files Browse the repository at this point in the history
  • Loading branch information
Wil Wilsman authored Jan 13, 2020
1 parent 871312f commit 6253c26
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/services/agent-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export class AgentService {
// serving a response for this CSS we're injecting into the DOM
if (snapshotOptions.percyCSS) {
const cssLink = `<link data-percy-specific-css rel="stylesheet" href="/${percyCSSFileName}" />`
domSnapshot = domSnapshot.replace(/<\/body>/i, cssLink + '$&')
domSnapshot = domSnapshot.replace(/(<\/body>)(?!.*\1)/is, cssLink + '$&')
}

resources = resources.concat(
Expand Down
1 change: 1 addition & 0 deletions test/integration/testcases/percy-specific-css.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<title>Percy Specific CSS testing</title>
</head>
<body>
<script> var test = "</body>" </script>
<div class="percy-only-css-snapshot"></div>
<div class="percy-only-css-global"></div>
</body>
Expand Down

0 comments on commit 6253c26

Please sign in to comment.