end_session_on_fail example?

683 views
Skip to first unread message

Kenneth Shaw

unread,
Apr 30, 2015, 6:04:27 AM4/30/15
to nightw...@googlegroups.com
Hi,

I was really excited to see that end_session_on_fail was added as an option this last week, but I am really struggling to get it working correctly.

I was wondering if there was a simple example of how to use it properly, especially in regards to running multiple test environments in parallel? I've been reading the nightwatch.js source and respective unit tests, but am not able to make heads nor tails of what I'm doing wrong. My understanding is that the session should fail on a bad assert, but move on to the next unit test. 

For reference, I am using nightwatch to test multiple browser interaction and coordination in parallel. Thanks in advance!

-Ken

Andrei Rusu

unread,
Apr 30, 2015, 7:39:16 AM4/30/15
to nightw...@googlegroups.com
Just set end_session_on_fail to false on your test_settings, inside
the desired environment - if you set it on "default" it will apply to
all. Remember to call client.end() in either the after or global
afterEach hook.
> --
> You received this message because you are subscribed to the Google Groups
> "NightwatchJs" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to nightwatchjs...@googlegroups.com.
> To post to this group, send email to nightw...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/nightwatchjs/1d8a40fe-84a9-4f81-8cdb-b6ca3e01cbb8%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Kenneth Shaw

unread,
Apr 30, 2015, 8:43:15 PM4/30/15
to nightw...@googlegroups.com
Ok -- I don't think I'm understanding this correctly then, because I believe that I had been doing that correctly. 

I've broken down the tests that I'm running into its simplest possible version, and its available here:


As you can see there is correctly a .afterEach that is calling both client.end(); and done();

For the test, we are launching two different chrome instances (each with different environments), and running it in parallel (see launch.sh for how the tests are launched).

Are the remaining test steps supposed to be skipped?  After the first failure, we get this:

 chrome2_2  FAILED:  1 assertions failed and 2 passed (9.626s)
 chrome2_2  
 chrome2_2  ----------------------------------------------------
 chrome2_2  TEST FAILURE: 1 assertions failed, 2 passed (9.658s)
 chrome2_2   ✖ ua
 chrome2_2  - chrome2_2 -- 0
 chrome2_2  Testing if element <body> contains text: "not present text". - Expected "not present text" but got: "ip_addr: 8.8.8.8
remote_host: 
user_agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36
port: 56990
lang: en-US,en;q=0.8
connection: keep-alive
keep_alive: 
encoding: gzip, deflate, sdch
mime: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
charset: 
via: 
forwarded: "
 chrome2_2     SKIPPED:
 chrome2_2  - chrome2_2 -- 1
   - chrome2_2 -- 2
 chrome2_2  - chrome2_2 -- 3
   - chrome2_2 -- 4
 chrome2_2  - chrome2_2 -- 5
 chrome2_2  - chrome2_2 -- 6
   - chrome2_2 -- 7
   - chrome2_2 -- 8
 chrome2_2  - chrome2_2 -- 9


Note that all the remaining tests are skipped. Is this the expected behavior? Again, my apologies in advance if I'm not understanding the behavior correctly here. My experience with other unit testing suites is that other tests within that "test" would continue after a failure, when configured to do so.

If this is not the right way to go about doing this (ie, breaking up test steps) within Nightwatch tests?

Tom Pietrosanti

unread,
Dec 9, 2015, 9:01:30 AM12/9/15
to NightwatchJs
I'm not sure if this came out after your question, but there is a "skip_testcases_on_fail" option that controls the behavior you're describing.  

I haven't tried this yet myself, but the combination of these two settings seems to be what you're looking for.  I hope it helps!

Kenneth Shaw

unread,
Dec 9, 2015, 9:20:33 AM12/9/15
to nightw...@googlegroups.com
Thanks, I appreciate the pointer. I asked this 7 months ago, and the
add skip_testcases_on_fail was added 6 months ago:

(commit 0e6023d6ed06d6965f88e2567597ed2273e681c3)

-Ken
> https://groups.google.com/d/msgid/nightwatchjs/fa29749d-8da4-4c67-bced-bfd50323031f%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages