-
-
Save kossnocorp/aa787ce40822d0ae50cb to your computer and use it in GitHub Desktop.
Power Assert with HTMLElement
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import stringifier from 'stringifier' | |
import typeName from 'type-name' | |
import htmlElementStringify from 'html-element-stringify' | |
import powerAssert from 'power-assert' | |
const assert = powerAssert.customize({ | |
output: { | |
stringify: stringifier({ | |
handlers: { | |
'HTMLElement': function(acc, el) { | |
acc.push(htmlElementStringify(el)) | |
} | |
}, | |
typeFun: function(arg) { | |
if (arg instanceof HTMLElement) { | |
return 'HTMLElement' | |
} else { | |
return typeName(arg) | |
} | |
} | |
}) | |
} | |
}) | |
it('has "test" text', ()=> { | |
const el = document.getElementById('playground') | |
assert(el.textContent.includes('test')) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment