0.0.1 • Published 9 years ago
dom-sandbox v0.0.1
dom-sandbox
super-simple dom sandboxing for tests
Why?
Often times during front-end testing you want to insert some HTML into the DOM or have a dummy element to render things into. This gives you a super-simple way to do that while also preventing you from:
- stomping on things that something like testling might need in the DOM
- creating tons of elements and forgetting to tear them down
- writing this boilerplate, albeit minimal
How?
var dom = require('dom-sandbox')
var testWidget = require('../widget/to/test')
dom('<div id="test-div"><span rel="something-necessary"></span></div>')
testWidget(document.getElementById('test-div'))
or
var dom = require('dom-sandbox')
var testWidget = require('../something/else')
testWidget(dom()) // pass the element directly
Notes
- Also provides a
.destroy()
method that removes the generated element from the DOM.
license
MIT