Skip to content

Instantly share code, notes, and snippets.

@thiagoa
Created November 4, 2016 14:35
Show Gist options
  • Save thiagoa/5639e644b59cbe82b336a4e9ae6df84f to your computer and use it in GitHub Desktop.
Save thiagoa/5639e644b59cbe82b336a4e9ae6df84f to your computer and use it in GitHub Desktop.
// spec/javascripts/support/createFixture.js
function createFixtureNode() {
const fixture = document.createElement('div');
fixture.id = 'fixture';
fixture.destroy = function destroy() {
this.parentNode.removeChild(fixture);
};
return fixture;
}
export default function createFixture({ html }) {
const fixture = createFixtureNode();
const body = document.querySelector('body');
fixture.innerHTML = html;
body.insertBefore(fixture, body.firstChild);
return fixture;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment