I've been trying to test my ES6 code using Tape assertions and Nightmare.js to load a test page. I keep trying different ES6 methods: async/await, yield, generators, and I think I'm a bit over my head. I'm also not sure when and when to not use babel-tape. I can get the following test to pass, but the minute I create another evaluate block it errors out. The documentation is fairly scarce (or uses Mocha). What's the best practice here?
import {test} from "tape";
import {default as nightmare} from "nightmare";
const page = nightmare().goto("http://localhost:4000/index.html");
page.evaluate(() => document.getElementsByTagName("body").length).end()
.then((result) => {
test("detect page body", (assert) => {
assert.equal(1, result);
assert.end();
});
});
ps. I'm using babel-tape-runner to run the tests.