Multiple single NightmareJS reports

Thanks to @pipo_dev, I was able to solve the problem that I had with several ratings in NightmareJS, one thing I would like to know is if I can provide multiple reports for the same test, take the following as an example:

describe('test google search results', function() { this.timeout(15000); it('should find the nightmare github link first', function(done) { var nightmare = Nightmare({show: true}) nightmare .goto('http://google.com') .wait(1000) .type('form[action*="/search"] [name=q]', 'github nightmare') .click('form[action*="/search"] [type=submit]') .wait(1000)//.wait('#rcnt') .evaluate(function() { return document.querySelector('div.rc h3.r a').href }) .then(function(link) { console.log("TESTING 1"); expect(link).to.equal('https://github.com/segmentio/nightmare'); nightmare .evaluate(function() { return document.querySelector('div.rc h3.r a').href }) .end() .then(function(link) { console.log("TESTING 2"); expect(link).to.equal('https://github.com/segmentio/nightmare'); done(); }) }) .catch(function(error) { done(new Error(error)) }) }); }); 

What I would like to see as a result:

 Test Google search results ✓ should find the nightmare github link first TEST 1 (8718ms) ✓ should find the nightmare github link first TEST 2 (8718ms) 

Instead, I am currently getting something like this:

 Test Google search results ✓ should find the nightmare github link first (8718ms) 

However, with the current setup, I get only one report for the whole test, maybe my approach is inefficient, but I need to run up to 100 tests in the user interface on one page and not rebuild the tests every time new tests start saving a lot of time.

0
source share
1 answer

After working with Nightmare, I was able to understand that I could create an instance of Nightmare and reuse it on other tests. Simplified version:

 describe('descr', function() { var ur = "http://www.helmutgranda.com"; var nightmare = new Nightmare{); nightmare.goto(url); it('first test', function(done) { nightmare .wait('element') .evaluate(....) .run(); } it('second test', function(done) { nightmare .wait('element') .evaluate(....) .run(); } }); 
+4
source

Source: https://habr.com/ru/post/1011786/


All Articles