Created
July 11, 2017 17:39
-
-
Save ndugger/2d9853436e8d3bf40860686a6addf410 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 { execFileSync } from 'child_process'; | |
| import { JSDOM } from 'jsdom'; | |
| const { Promise } = global; | |
| const options = { resources: 'usable', runScripts: 'dangerously' }; | |
| const server = execFileSync('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); | |
| const { window } = dom; | |
| Object.assign(browser, { window }); | |
| await new Promise(resolve => window.addEventListener('load', resolve)); | |
| }); | |
| afterAll(() => { | |
| server.kill(); | |
| }); | |
| describe('...', () => { | |
| test('...', () => { | |
| console.log(browser.window.document.body.outerHTML); | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment