Kudos to zewa666 for the pointer to nightmare.js – works like a champ!
#1 yarn add --dev nightmare
#2 create a file: test/e2e/nightmare.spec.js
import nightmare from 'nightmare';
describe('When starting the app', function () {
test('it shows out of service', async function () {
let page = nightmare({
show: true,
dock: true,
openDevTools: {
mode: 'detach'
}
}).goto('http://localhost:8080');
let text = await page.evaluate(() => document.body.textContent)
.wait(3000)
.end();
expect(text).toContain('out of service');
});
});
#3 au run --watch
#4 au jest (in a different session)
The gorgeous result: a window opens showing the out-of-service page, another opens showing the dev console, then jest passes the test, and nightmare waits 3 seconds before closing up and everything shuts down.
I am sure that I’ll have a set of problems to work through getting all my tests re-written – but who cares!!
Total bonus to be right there with proper async/await !!
as a side note, I discovered that having the dev tools open can cause the screenshot function to hang – so be sure not to open dev tools after you’re done setting up your tests !