summaryrefslogtreecommitdiff
path: root/spec/frontend_integration/test_helpers/snapshot_serializer.js
diff options
context:
space:
mode:
Diffstat (limited to 'spec/frontend_integration/test_helpers/snapshot_serializer.js')
-rw-r--r--spec/frontend_integration/test_helpers/snapshot_serializer.js18
1 files changed, 18 insertions, 0 deletions
diff --git a/spec/frontend_integration/test_helpers/snapshot_serializer.js b/spec/frontend_integration/test_helpers/snapshot_serializer.js
new file mode 100644
index 00000000000..8c4f95a9156
--- /dev/null
+++ b/spec/frontend_integration/test_helpers/snapshot_serializer.js
@@ -0,0 +1,18 @@
+export default {
+ test(value) {
+ return value instanceof HTMLElement && !value.$_hit;
+ },
+ print(element, serialize) {
+ element.$_hit = true;
+ element.querySelectorAll('[style]').forEach(el => {
+ 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');
+ },
+};