Last active
February 9, 2018 19:43
-
-
Save dsadhanala/36e2732899e64c0f15f45b69e3befa19 to your computer and use it in GitHub Desktop.
setup browser env in node with basicHTML
This file contains 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
// 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