Last active
July 31, 2017 00:26
-
-
Save mjbogusz/47d92607551b556d1d5a78613194463e to your computer and use it in GitHub Desktop.
Nightwatch.js client.perform() issues examples
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "src_folders" : ["src"], | |
| "output_folder" : "reports", | |
| "custom_commands_path" : "", | |
| "custom_assertions_path" : "", | |
| "page_objects_path" : "", | |
| "globals_path" : "", | |
| "selenium" : { | |
| "start_process" : true, | |
| "server_path" : "./node_modules/selenium-standalone/.selenium/selenium-server/3.4.0-server.jar", | |
| "log_path" : "", | |
| "port" : 4444, | |
| "cli_args" : { | |
| "webdriver.chrome.driver": "./node_modules/selenium-standalone/.selenium/chromedriver/2.30-x64-chromedriver", | |
| "webdriver.gecko.driver" : "./node_modules/selenium-standalone/.selenium/geckodriver/0.18.0-x64-geckodriver" | |
| } | |
| }, | |
| "test_settings" : { | |
| "default" : { | |
| "launch_url" : "http://localhost", | |
| "selenium_port" : 4444, | |
| "selenium_host" : "localhost", | |
| "silent": true, | |
| "persist_globals": true, | |
| "screenshots" : { | |
| "enabled" : false, | |
| "path" : "" | |
| }, | |
| "desiredCapabilities": { | |
| "browserName": "firefox", | |
| "marionette": true | |
| } | |
| } | |
| }, | |
| "live_output": true, | |
| "test_runner": { | |
| "type": "mocha", | |
| "options": { | |
| "ui": "bdd", | |
| "reporter": "list" | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const nodeAssert = require('assert'); | |
| describe('Nightwatch perform() error test', () => { | |
| after((client, done) => { | |
| client.end(done.bind(done, null)); | |
| }); | |
| it('should fail a test where sync perform throws', client => { | |
| // Does not fail | |
| client.perform(() => { | |
| throw new Error('test error'); | |
| }); | |
| }); | |
| it('should fail a test where sync perform fails a nightwatch assert', client => { | |
| // Works | |
| client.perform(() => { | |
| client.assert.ok(false); | |
| }); | |
| }); | |
| it('should fail a test where sync perform fails a node assert', client => { | |
| // Works | |
| client.perform(() => { | |
| nodeAssert(false); | |
| }); | |
| }); | |
| it('should fail a test where async perform ends with an error', client => { | |
| // Does not fail | |
| client.perform((api, done) => { | |
| done(new Error('test error 2.1')); | |
| }); | |
| }); | |
| it.skip('should fail a test where async perform throws', client => { | |
| // Crashes whole process | |
| client.perform((api, done) => { | |
| throw new Error('test error 2'); | |
| }); | |
| }); | |
| it('should fail a test where async perform ends with an error after some time', client => { | |
| // Does not dail, causes mangled output | |
| client.perform((api, done) => { | |
| setTimeout(() => { | |
| done(new Error('test error 4')); | |
| }, 1000); | |
| }); | |
| }); | |
| it.skip('should fail a test where async perform throws after some time', client => { | |
| // Crashes whole process | |
| client.perform((api, done) => { | |
| setTimeout(() => { | |
| throw new Error('test error 3'); | |
| }, 1000); | |
| setTimeout(() => { | |
| done(new Error('fake timeout')); | |
| }, 10000); | |
| }); | |
| }); | |
| it('should fail a test where async perform fails a nightwatch assert', client => { | |
| // Works | |
| client.perform((api, done) => { | |
| setTimeout(() => { | |
| api.assert.ok(false); | |
| }, 1000); | |
| setTimeout(() => { | |
| done(new Error('fake timeout')); | |
| }, 10000); | |
| }); | |
| }); | |
| it.skip('should fail a test where async perform fails a node assert', client => { | |
| // Crashes whole process | |
| client.perform((api, done) => { | |
| setTimeout(() => { | |
| nodeAssert(false); | |
| }, 1000); | |
| setTimeout(() => { | |
| done(new Error('fake timeout')); | |
| }, 10000); | |
| }); | |
| }); | |
| it('should fail a test where async perform does not end', client => { | |
| // Does not fail (timeout), does not fail on fake timeout error too | |
| client.perform((api, done) => { | |
| setInterval(() => { | |
| console.log('not ending yet'); | |
| }, 1000); | |
| setTimeout(() => { | |
| done(new Error('fake timeout')); | |
| }, 10000); | |
| }); | |
| }); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Starting selenium server... started - PID: 28070 | |
| ✓ Nightwatch perform() error test should fail a test where sync perform throws: 3474ms | |
| 1) Nightwatch perform() error test should fail a test where sync perform fails a nightwatch assert | |
| 2) Nightwatch perform() error test should fail a test where sync perform fails a node assert | |
| ✓ Nightwatch perform() error test should fail a test where async perform ends with an error: 2617ms | |
| - Nightwatch perform() error test should fail a test where async perform throws | |
| Nightwatch perform() error test should fail a test where async perform ends with an error after ✓ Nightwatch perform() error test should fail a test where async perform ends with an error after some time: 1003ms | |
| - Nightwatch perform() error test should fail a test where async perform throws after some time | |
| 3) Nightwatch perform() error test should fail a test where async perform fails a nightwatch assert | |
| - Nightwatch perform() error test should fail a test where async perform fails a node assert | |
| Nightwatch perform() error test should fail a test where async perform does not end: not ending yet | |
| not ending yet | |
| not ending yet | |
| not ending yet | |
| not ending yet | |
| not ending yet | |
| not ending yet | |
| not ending yet | |
| not ending yet | |
| ✓ Nightwatch perform() error test should fail a test where async perform does not end: 12603ms | |
| not ending yet | |
| 4 passing (37s) | |
| 3 pending | |
| 3 failing | |
| 1) Nightwatch perform() error test should fail a test where sync perform fails a nightwatch assert: | |
| Failed [ok]: (false == true) - Expected "true" but got: "false" | |
| at F.client.perform (src/nightwatch_perform_test.js:17:18) | |
| 2) Nightwatch perform() error test should fail a test where sync perform fails a node assert: | |
| Failed [ok]: (false == true) - Expected "true" but got: "false" | |
| at F.client.perform (src/nightwatch_perform_test.js:17:18) | |
| 3) Nightwatch perform() error test should fail a test where async perform fails a nightwatch assert: | |
| Failed [ok]: (false == true) - Expected "true" but got: "false" | |
| at Timeout.setTimeout [as _onTimeout] (src/nightwatch_perform_test.js:55:16) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Starting selenium server... started - PID: 30253 | |
| Nightwatch perform() error test should fail a test where sync perform throws: INFO Request: POST /wd/hub/session | |
| - data: {"desiredCapabilities":{"browserName":"firefox","javascriptEnabled":true,"acceptSslCerts":true,"platform":"ANY","marionette":true}} | |
| - headers: {"Content-Type":"application/json; charset=utf-8","Content-Length":131} | |
| INFO Response 200 POST /wd/hub/session (2997ms) { state: null, | |
| sessionId: 'f22c22d6-8b77-4ac1-b69c-f223c2cc292c', | |
| hCode: 352136189, | |
| value: | |
| { 'moz:profile': '/tmp/rust_mozprofile.uyrCH2aMvJGZ', | |
| rotatable: false, | |
| timeouts: { implicit: 0, pageLoad: 300000, script: 30000 }, | |
| pageLoadStrategy: 'normal', | |
| platform: 'ANY', | |
| specificationLevel: 0, | |
| 'moz:accessibilityChecks': false, | |
| 'webdriver.remote.sessionid': 'f22c22d6-8b77-4ac1-b69c-f223c2cc292c', | |
| acceptInsecureCerts: false, | |
| browserVersion: '54.0.1', | |
| platformVersion: '4.12.3-1-ARCH', | |
| 'moz:processID': 30301, | |
| browserName: 'firefox', | |
| takesScreenshot: true, | |
| javascriptEnabled: true, | |
| platformName: 'linux', | |
| cssSelectorsEnabled: true }, | |
| class: 'org.openqa.selenium.remote.Response', | |
| status: 0 } | |
| INFO Got sessionId from selenium f22c22d6-8b77-4ac1-b69c-f223c2cc292c | |
| INFO Request: DELETE /wd/hub/session/f22c22d6-8b77-4ac1-b69c-f223c2cc292c | |
| - data: | |
| - headers: {"Content-Length":0} | |
| INFO Response 200 DELETE /wd/hub/session/f22c22d6-8b77-4ac1-b69c-f223c2cc292c (418ms) { state: 'success', | |
| sessionId: 'f22c22d6-8b77-4ac1-b69c-f223c2cc292c', | |
| hCode: 877817257, | |
| value: null, | |
| class: 'org.openqa.selenium.remote.Response', | |
| status: 0 } | |
| INFO FINISHED | |
| ✓ Nightwatch perform() error test should fail a test where sync perform throws: 3426ms | |
| LOG → Completed command end (422 ms) | |
| LOG → Completed command session (421 ms) | |
| Nightwatch perform() error test should fail a test where sync perform fails a nightwatch assert: INFO Request: POST /wd/hub/session | |
| - data: {"desiredCapabilities":{"browserName":"firefox","javascriptEnabled":true,"acceptSslCerts":true,"platform":"ANY","marionette":true}} | |
| - headers: {"Content-Type":"application/json; charset=utf-8","Content-Length":131} | |
| INFO Response 200 POST /wd/hub/session (3190ms) { state: null, | |
| sessionId: '97bf2eb1-e0c2-4756-b237-984d2a011447', | |
| hCode: 1773961648, | |
| value: | |
| { 'moz:profile': '/tmp/rust_mozprofile.CVOHyyVTto2Q', | |
| rotatable: false, | |
| timeouts: { implicit: 0, pageLoad: 300000, script: 30000 }, | |
| pageLoadStrategy: 'normal', | |
| platform: 'ANY', | |
| specificationLevel: 0, | |
| 'moz:accessibilityChecks': false, | |
| 'webdriver.remote.sessionid': '97bf2eb1-e0c2-4756-b237-984d2a011447', | |
| acceptInsecureCerts: false, | |
| browserVersion: '54.0.1', | |
| platformVersion: '4.12.3-1-ARCH', | |
| 'moz:processID': 30439, | |
| browserName: 'firefox', | |
| takesScreenshot: true, | |
| javascriptEnabled: true, | |
| platformName: 'linux', | |
| cssSelectorsEnabled: true }, | |
| class: 'org.openqa.selenium.remote.Response', | |
| status: 0 } | |
| INFO Got sessionId from selenium 97bf2eb1-e0c2-4756-b237-984d2a011447 | |
| LOG → Completed command perform (3 ms) | |
| INFO Request: DELETE /wd/hub/session/97bf2eb1-e0c2-4756-b237-984d2a011447 | |
| - data: | |
| - headers: {"Content-Length":0} | |
| INFO Response 200 DELETE /wd/hub/session/97bf2eb1-e0c2-4756-b237-984d2a011447 (418ms) { state: 'success', | |
| sessionId: '97bf2eb1-e0c2-4756-b237-984d2a011447', | |
| hCode: 1311020555, | |
| value: null, | |
| class: 'org.openqa.selenium.remote.Response', | |
| status: 0 } | |
| INFO FINISHED | |
| 1) Nightwatch perform() error test should fail a test where sync perform fails a nightwatch assert | |
| LOG → Completed command end (420 ms) | |
| LOG → Completed command session (420 ms) | |
| Nightwatch perform() error test should fail a test where sync perform fails a node assert: INFO Request: POST /wd/hub/session | |
| - data: {"desiredCapabilities":{"browserName":"firefox","javascriptEnabled":true,"acceptSslCerts":true,"platform":"ANY","marionette":true}} | |
| - headers: {"Content-Type":"application/json; charset=utf-8","Content-Length":131} | |
| INFO Response 200 POST /wd/hub/session (2576ms) { state: null, | |
| sessionId: 'c813b5e7-6009-4255-9345-1b9191c92105', | |
| hCode: 1247543081, | |
| value: | |
| { 'moz:profile': '/tmp/rust_mozprofile.NbmApWTFsoHe', | |
| rotatable: false, | |
| timeouts: { implicit: 0, pageLoad: 300000, script: 30000 }, | |
| pageLoadStrategy: 'normal', | |
| platform: 'ANY', | |
| specificationLevel: 0, | |
| 'moz:accessibilityChecks': false, | |
| 'webdriver.remote.sessionid': 'c813b5e7-6009-4255-9345-1b9191c92105', | |
| acceptInsecureCerts: false, | |
| browserVersion: '54.0.1', | |
| platformVersion: '4.12.3-1-ARCH', | |
| 'moz:processID': 30581, | |
| browserName: 'firefox', | |
| takesScreenshot: true, | |
| javascriptEnabled: true, | |
| platformName: 'linux', | |
| cssSelectorsEnabled: true }, | |
| class: 'org.openqa.selenium.remote.Response', | |
| status: 0 } | |
| INFO Got sessionId from selenium c813b5e7-6009-4255-9345-1b9191c92105 | |
| INFO Request: DELETE /wd/hub/session/c813b5e7-6009-4255-9345-1b9191c92105 | |
| - data: | |
| - headers: {"Content-Length":0} | |
| INFO Response 200 DELETE /wd/hub/session/c813b5e7-6009-4255-9345-1b9191c92105 (421ms) { state: 'success', | |
| sessionId: 'c813b5e7-6009-4255-9345-1b9191c92105', | |
| hCode: 539339943, | |
| value: null, | |
| class: 'org.openqa.selenium.remote.Response', | |
| status: 0 } | |
| INFO FINISHED | |
| 2) Nightwatch perform() error test should fail a test where sync perform fails a node assert | |
| LOG → Completed command end (422 ms) | |
| LOG → Completed command session (422 ms) | |
| Nightwatch perform() error test should fail a test where async perform ends with an error: INFO Request: POST /wd/hub/session | |
| - data: {"desiredCapabilities":{"browserName":"firefox","javascriptEnabled":true,"acceptSslCerts":true,"platform":"ANY","marionette":true}} | |
| - headers: {"Content-Type":"application/json; charset=utf-8","Content-Length":131} | |
| INFO Response 200 POST /wd/hub/session (2551ms) { state: null, | |
| sessionId: '8e6beeb3-395c-46d5-89b6-e6cb32e84917', | |
| hCode: 150403249, | |
| value: | |
| { 'moz:profile': '/tmp/rust_mozprofile.FqIXe8jdDxum', | |
| rotatable: false, | |
| timeouts: { implicit: 0, pageLoad: 300000, script: 30000 }, | |
| pageLoadStrategy: 'normal', | |
| platform: 'ANY', | |
| specificationLevel: 0, | |
| 'moz:accessibilityChecks': false, | |
| 'webdriver.remote.sessionid': '8e6beeb3-395c-46d5-89b6-e6cb32e84917', | |
| acceptInsecureCerts: false, | |
| browserVersion: '54.0.1', | |
| platformVersion: '4.12.3-1-ARCH', | |
| 'moz:processID': 30726, | |
| browserName: 'firefox', | |
| takesScreenshot: true, | |
| javascriptEnabled: true, | |
| platformName: 'linux', | |
| cssSelectorsEnabled: true }, | |
| class: 'org.openqa.selenium.remote.Response', | |
| status: 0 } | |
| INFO Got sessionId from selenium 8e6beeb3-395c-46d5-89b6-e6cb32e84917 | |
| LOG → Completed command perform (0 ms) | |
| INFO FINISHED | |
| ✓ Nightwatch perform() error test should fail a test where async perform ends with an error: 2553ms | |
| - Nightwatch perform() error test should fail a test where async perform throws | |
| Nightwatch perform() error test should fail a test where async perform ends with an error after some time: LOG → Completed command perform (1004 ms) | |
| INFO FINISHED | |
| ✓ Nightwatch perform() error test should fail a test where async perform ends with an error after some time: 1005ms | |
| - Nightwatch perform() error test should fail a test where async perform throws after some time | |
| Nightwatch perform() error test should fail a test where async perform fails a nightwatch assert: LOG → Completed command perform (10011 ms) | |
| INFO Request: DELETE /wd/hub/session/8e6beeb3-395c-46d5-89b6-e6cb32e84917 | |
| - data: | |
| - headers: {"Content-Length":0} | |
| INFO Response 200 DELETE /wd/hub/session/8e6beeb3-395c-46d5-89b6-e6cb32e84917 (463ms) { state: 'success', | |
| sessionId: '8e6beeb3-395c-46d5-89b6-e6cb32e84917', | |
| hCode: 801373317, | |
| value: null, | |
| class: 'org.openqa.selenium.remote.Response', | |
| status: 0 } | |
| INFO FINISHED | |
| 3) Nightwatch perform() error test should fail a test where async perform fails a nightwatch assert | |
| LOG → Completed command end (466 ms) | |
| LOG → Completed command session (465 ms) | |
| - Nightwatch perform() error test should fail a test where async perform fails a node assert | |
| Nightwatch perform() error test should fail a test where async perform does not end: INFO Request: POST /wd/hub/session | |
| - data: {"desiredCapabilities":{"browserName":"firefox","javascriptEnabled":true,"acceptSslCerts":true,"platform":"ANY","marionette":true}} | |
| - headers: {"Content-Type":"application/json; charset=utf-8","Content-Length":131} | |
| INFO Response 200 POST /wd/hub/session (2574ms) { state: null, | |
| sessionId: '3aa5fefe-a504-4b65-8bef-47a78fcde68b', | |
| hCode: 2079916071, | |
| value: | |
| { 'moz:profile': '/tmp/rust_mozprofile.rbEU5u9m91y3', | |
| rotatable: false, | |
| timeouts: { implicit: 0, pageLoad: 300000, script: 30000 }, | |
| pageLoadStrategy: 'normal', | |
| platform: 'ANY', | |
| specificationLevel: 0, | |
| 'moz:accessibilityChecks': false, | |
| 'webdriver.remote.sessionid': '3aa5fefe-a504-4b65-8bef-47a78fcde68b', | |
| acceptInsecureCerts: false, | |
| browserVersion: '54.0.1', | |
| platformVersion: '4.12.3-1-ARCH', | |
| 'moz:processID': 30895, | |
| browserName: 'firefox', | |
| takesScreenshot: true, | |
| javascriptEnabled: true, | |
| platformName: 'linux', | |
| cssSelectorsEnabled: true }, | |
| class: 'org.openqa.selenium.remote.Response', | |
| status: 0 } | |
| INFO Got sessionId from selenium 3aa5fefe-a504-4b65-8bef-47a78fcde68b | |
| not ending yet | |
| not ending yet | |
| not ending yet | |
| not ending yet | |
| not ending yet | |
| not ending yet | |
| not ending yet | |
| not ending yet | |
| not ending yet | |
| LOG → Completed command perform (10002 ms) | |
| INFO FINISHED | |
| ✓ Nightwatch perform() error test should fail a test where async perform does not end: 12581ms | |
| INFO Request: DELETE /wd/hub/session/3aa5fefe-a504-4b65-8bef-47a78fcde68b | |
| - data: | |
| - headers: {"Content-Length":0} | |
| not ending yet | |
| INFO Response 200 DELETE /wd/hub/session/3aa5fefe-a504-4b65-8bef-47a78fcde68b (461ms) { state: 'success', | |
| sessionId: '3aa5fefe-a504-4b65-8bef-47a78fcde68b', | |
| hCode: 731381682, | |
| value: null, | |
| class: 'org.openqa.selenium.remote.Response', | |
| status: 0 } | |
| LOG → Completed command end (464 ms) | |
| LOG → Completed command session (463 ms) | |
| INFO FINISHED | |
| 4 passing (37s) | |
| 3 pending | |
| 3 failing | |
| 1) Nightwatch perform() error test should fail a test where sync perform fails a nightwatch assert: | |
| Failed [ok]: (false == true) - Expected "true" but got: "false" | |
| at F.client.perform (src/nightwatch_perform_test.js:19:18) | |
| 2) Nightwatch perform() error test should fail a test where sync perform fails a node assert: | |
| Failed [ok]: (false == true) - Expected "true" but got: "false" | |
| at F.client.perform (src/nightwatch_perform_test.js:19:18) | |
| 3) Nightwatch perform() error test should fail a test where async perform fails a nightwatch assert: | |
| Failed [ok]: (false == true) - Expected "true" but got: "false" | |
| at Timeout.setTimeout [as _onTimeout] (src/nightwatch_perform_test.js:63:16) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment