Skip to content

Instantly share code, notes, and snippets.

@dsadhanala
Last active February 9, 2018 19:43
Show Gist options
  • Save dsadhanala/36e2732899e64c0f15f45b69e3befa19 to your computer and use it in GitHub Desktop.
Save dsadhanala/36e2732899e64c0f15f45b69e3befa19 to your computer and use it in GitHub Desktop.
setup browser env in node with basicHTML
// setup browser env
const { Document, HTMLElement } = require('basichtml');
global.window = global;
global.document = new Document();
global.customElements = document.customElements;
global.HTMLElement = HTMLElement;
// mock missing api
document.importNode = (node, deep) => node.cloneNode(deep);
global.requestAnimationFrame = (callback) => setTimeout(callback, 0);
// setup chai
const { expect, should, assert } = require('chai');
global.expect = expect;
global.should = should;
global.assert = assert;
const hyperHTML = require("hyperhtml");
const cssClassName = 'test-class';
hyperHTML.bind(document.body)`<div class="${cssClassName}"></div>`;
document.toString();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment