Created
July 11, 2017 21:06
-
-
Save ndugger/108b835a450ab9d5eb48d05274cafef4 to your computer and use it in GitHub Desktop.
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
import { execFile } from 'child_process'; | |
import { JSDOM } from 'jsdom'; | |
const { Promise } = global; | |
const options = { resources: 'usable', runScripts: 'dangerously' }; | |
const server = execFile('node', [ './dist/server/index.js' ], { cwd: process.cwd() }); | |
const browser = { }; | |
beforeAll(async () => { | |
await new Promise(resolve => setTimeout(resolve, 2000)); | |
const dom = await JSDOM.fromURL('http://localhost:8080', options); | |
await new Promise(resolve => dom.window.addEventListener('load', resolve)); | |
Object.assign(browser, { window: dom.window }); | |
}); | |
afterAll(() => { | |
server.kill(); | |
}); | |
describe('...', () => { | |
test('...', () => { | |
const { document } = browser.window; | |
const draggable = document.querySelectorAll('[draggable]'); | |
expect(draggable.length).toBe(12); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment