From 2fbd969ab88ddb164b326a6e4f514771f56a8ceb Mon Sep 17 00:00:00 2001 From: Gleb Bahmutov Date: Wed, 13 Dec 2017 16:26:12 -0500 Subject: [PATCH] fix: use Cypress.dom.isJquery, close #8 --- .gitignore | 1 + src/index.js | 5 ++--- src/utils.js | 7 +------ 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index 625212a..33c6e20 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ node_modules/ .DS_Store npm-debug.log +cypress/videos/ diff --git a/src/index.js b/src/index.js index de70c4a..dffc7bc 100644 --- a/src/index.js +++ b/src/index.js @@ -8,7 +8,6 @@ const is = require('check-more-types') const compare = require('snap-shot-compare') const { - isJqueryElement, serializeDomElement, serializeReactToHTML, identity, @@ -93,7 +92,7 @@ function registerCypressSnapshot () { const devToolsLog = { value } - if (isJqueryElement($el)) { + if (Cypress.dom.isJquery($el)) { // only add DOM elements, otherwise "expected" value is enough devToolsLog.$el = $el } @@ -134,7 +133,7 @@ function registerCypressSnapshot () { } const pickSerializer = (asJson, value) => { - if (isJqueryElement(value)) { + if (Cypress.dom.isJquery(value)) { return asJson ? serializeDomElement : serializeReactToHTML } return identity diff --git a/src/utils.js b/src/utils.js index c898af3..54933ba 100644 --- a/src/utils.js +++ b/src/utils.js @@ -1,10 +1,6 @@ const sd = require('@wildpeaks/snapshot-dom') const beautify = require('js-beautify').html -function isJqueryElement (x) { - return x && typeof x === 'object' && 'wrap' in x -} - // converts DOM element to a JSON object function serializeDomElement ($el) { // console.log('snapshot value!', $el) @@ -61,6 +57,5 @@ module.exports = { serializeDomElement, serializeReactToHTML, identity, - countSnapshots, - isJqueryElement + countSnapshots }