fix: use Cypress.dom.isJquery, close #8

This commit is contained in:
Gleb Bahmutov 2017-12-13 16:26:12 -05:00
parent fe03042087
commit 2fbd969ab8
3 changed files with 4 additions and 9 deletions

1
.gitignore vendored
View file

@ -1,3 +1,4 @@
node_modules/ node_modules/
.DS_Store .DS_Store
npm-debug.log npm-debug.log
cypress/videos/

View file

@ -8,7 +8,6 @@ const is = require('check-more-types')
const compare = require('snap-shot-compare') const compare = require('snap-shot-compare')
const { const {
isJqueryElement,
serializeDomElement, serializeDomElement,
serializeReactToHTML, serializeReactToHTML,
identity, identity,
@ -93,7 +92,7 @@ function registerCypressSnapshot () {
const devToolsLog = { const devToolsLog = {
value value
} }
if (isJqueryElement($el)) { if (Cypress.dom.isJquery($el)) {
// only add DOM elements, otherwise "expected" value is enough // only add DOM elements, otherwise "expected" value is enough
devToolsLog.$el = $el devToolsLog.$el = $el
} }
@ -134,7 +133,7 @@ function registerCypressSnapshot () {
} }
const pickSerializer = (asJson, value) => { const pickSerializer = (asJson, value) => {
if (isJqueryElement(value)) { if (Cypress.dom.isJquery(value)) {
return asJson ? serializeDomElement : serializeReactToHTML return asJson ? serializeDomElement : serializeReactToHTML
} }
return identity return identity

View file

@ -1,10 +1,6 @@
const sd = require('@wildpeaks/snapshot-dom') const sd = require('@wildpeaks/snapshot-dom')
const beautify = require('js-beautify').html const beautify = require('js-beautify').html
function isJqueryElement (x) {
return x && typeof x === 'object' && 'wrap' in x
}
// converts DOM element to a JSON object // converts DOM element to a JSON object
function serializeDomElement ($el) { function serializeDomElement ($el) {
// console.log('snapshot value!', $el) // console.log('snapshot value!', $el)
@ -61,6 +57,5 @@ module.exports = {
serializeDomElement, serializeDomElement,
serializeReactToHTML, serializeReactToHTML,
identity, identity,
countSnapshots, countSnapshots
isJqueryElement
} }