-
-
Save obengwilliam/e63a0b3616e44ccb815e02c9deaaf871 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 { 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