Skip to content

Commit

Permalink
fix(snapshots): ignore data-lwc-host-scope-token (#339)
Browse files Browse the repository at this point in the history
  • Loading branch information
nolanlawson authored Nov 18, 2024
1 parent 46d81a5 commit 98dbd26
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/@lwc/jest-preset/src/ssr/html-serializer.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ function formatHTML(src) {
// `data-lwc-host-mutated` may or may not have an attribute value depending on the version of LWC.
// See: https://github.com/salesforce/lwc/pull/4385
.replace(/ data-lwc-host-mutated(="[^"]*")?/g, '')
.replace(/ data-lwc-host-scope-token(="[^"]*")?/g, '')
.replace(/ data-rendered-by-lwc/g, '')
);
}
Expand Down
1 change: 1 addition & 0 deletions packages/@lwc/jest-serializer/src/clean-element-attrs.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const { isKnownScopeToken } = require('@lwc/jest-shared');
const ATTRS_TO_REMOVE = [
'lwc:host', // https://github.com/salesforce/lwc/pull/1600
'data-lwc-host-mutated', // https://github.com/salesforce/lwc/pull/4358
'data-lwc-host-scope-token', // https://github.com/salesforce/lwc/pull/4865
];

function cleanElementAttributes(elm) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ export default class FrameworkAttrsWithValue extends LightningElement {
// Typically this is only added by the framework itself, but here we are explicitly adding it
// to make the test simpler
this.setAttribute('data-lwc-host-mutated', 'class data-foo');
this.setAttribute('data-lwc-host-scope-token', 'foo');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ export default class FrameworkAttrsWithValue extends LightningElement {
// Typically this is only added by the framework itself, but here we are explicitly adding it
// to make the test simpler
this.setAttribute('data-lwc-host-mutated', 'class data-foo');
this.setAttribute('data-lwc-host-scope-token', 'foo');
}
}

0 comments on commit 98dbd26

Please sign in to comment.