Skip to content

Instantly share code, notes, and snippets.

@kossnocorp
Last active September 26, 2015 02:38
Show Gist options
  • Save kossnocorp/aa787ce40822d0ae50cb to your computer and use it in GitHub Desktop.
Save kossnocorp/aa787ce40822d0ae50cb to your computer and use it in GitHub Desktop.
Power Assert with HTMLElement
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