ecmascript 6 - ES6 javascript tests using Tape and Nightmare.js -
i've been trying test es6 code using tape assertions , nightmare.js load test page. keep trying different es6 methods: async/await, yield, generators, , think i'm bit on head. i'm not sure when , when not use babel-tape. can following test pass, minute create evaluate block errors out. documentation scarce (or uses mocha). what's best practice here?
import {test} "tape"; import {default nightmare} "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 run tests.
i can following test pass, minute create evaluate block errors out.
hm, you're calling .end()
on nightmare instance. shouldn't interacting instance once ends, causing of problems.
the documentation scarce (or uses mocha)
if take @ test suite in nightmare, describe
blocks have beforeeach
, aftereach
sets or destroys nightmare instance, respectively. test - @ least in read - set single nightmare instance of tests, may lead undesirable behavior.
all said, might want try moving declaration , usage of nightmare internal tests. off cuff, like:
import {test} "tape"; import {default nightmare} "nightmare"; test('detect page body', (assert) => { var nightmare = nightmare(); nightmare .goto("http://localhost:4000/index.html") .evaluate(() => document.getelementsbytagname("body").length) .then((result) => { assert.equal(1, result); nightmare.end(()=>{ assert.end(); }); }); });
Comments
Post a Comment