debian-mirror-gitlab/spec/frontend_integration/test_helpers/snapshot_serializer.js

19 lines
452 B
JavaScript
Raw Normal View History

2020-10-24 23:57:45 +05:30
export default {
test(value) {
return value instanceof HTMLElement && !value.$_hit;
},
print(element, serialize) {
element.$_hit = true;
2021-03-08 18:12:59 +05:30
element.querySelectorAll('[style]').forEach((el) => {
2020-10-24 23:57:45 +05:30
el.$_hit = true;
if (el.style.display === 'none') {
el.textContent = '(jest: contents hidden)';
}
});
return serialize(element)
.replace(/^\s*<!---->$/gm, '')
.replace(/\n\s*\n/gm, '\n');
},
};