question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Wrong error (allElements.shift not a function) showing in test summary

See original GitHub issue

We have many tests that make use of sections. Whenever one of these tests contains a call to verify an element within a section and the test fails, the correct error is reported, along with the allElements.shift is not a function error. Unfortunately, the final test summary at the end of the test run ONLY reports the allElements.shift error, instead of the correct, more helpful error that the element being sought was not available.

For example:

My test has the following line: this.section.userMenu.expect.element('@logOff').to.be.visible

If the expectation fails when the test runs, I see:

 ✖ Expected element <Section[name=accountDropDown],Element[name=@signOut]> to be visible  - expected "visible" but got: "not visible"
    at Object.commands.assertLogoutButton (/app/e2e/pages/global.js:51:41)
    at Object.module.exports.before.Throws an error for an incorrect login.Logs in with a valid user (/app/e2e/tests/login/login.spec.js:19:16)

The test then automatically retries. When this happens, an earlier validation (which occurs inside an iframe), which passed on the first attempt, now fails on the second attempt:

this.api.frame('login_iframe').waitForElementPresent('main_page_content')

Then, when the suite completes, that failure reports as:

TEST FAILURE: 1 error during execution,  0 assertions failed, 6 passed. (42.602s)

 ✖ login/login.spec

   - Throws an error for an incorrect login (7.581s)

   Error while running waitForElementPresent command: allElements.shift is not a function
       at Object.setCredentialFields (/app/e2e/pages/login.js:63:8)
       at Object.commands.loginFlow (/app/e2e/pages/login.js:40:10)
       at Object.module.exports.before.Throws an error for an incorrect login (/app/e2e/tests/login/login.spec.js:13:15)

Summary:

  1. It would be helpful if the summary output would include the original error during the test’s first attempt, rather than the second attempt.
  2. It would be helpful if the waitForElementPresent error were reported rather than the allElements.shift internal error when a waitForElementPresent check is executed.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
tnguyen14commented, Jun 23, 2017

I’m seeing this error in the retries after a command failure. Does anyone know if this is already fixed?

Retrying (1/7):  Remembers the computer                                                                                                                      
 ✔ Testing if element <body> contains text: "cleared".                                                                                                       
 ✔ Element <#content> was visible after 2846 milliseconds.                                                                                                   
 ✔ Element <Section[name=loginForm],Element[name=@usernameField]> was visible after 489 milliseconds.                                                        
 ✖ Timed out while waiting for element <Section[name=twoFactorForm],Element[name=@tokenField]> to be present for 10000 milliseconds.  - expected "visible" but got: "not found"
    at Object.verify2fa (/home/tri/app/test/nightwatch/pageObjects/login.js:48:10)                              
    at Object.Remembers the computer (/home/tri/app/test/nightwatch/login.js:114:8)                             
                                                                                                                                                             
                                                                                                                                                             
Retrying (2/7):  Remembers the computer                                                                                                                      
Error while running getText command: allElements.shift is not a function                                                                                     
    at command (/home/tri/app/node_modules/nightwatch/lib/api/assertions/containsText.js:46:21)                 
    at module.exports.BaseAssertion._scheduleAssertion (/home/tri/app/node_modules/nightwatch/lib/core/assertion.js:87:17)

0reactions
beatfactorcommented, May 1, 2018

Should be fixed in v1.0.4.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ancestors.shift is not a function - javascript
I'm trying to get automated tests back up and running and having the following issue when I run a test. The objective of...
Read more >
Array.prototype.every() - JavaScript - MDN Web Docs
The every() method tests whether all elements in the array pass the test implemented by the provided function. It returns a Boolean value....
Read more >
All elements in an array are Same or not?
Given an array, check whether all elements in an array are the same or not. Examples: Input : "Geeks", "for", "Geeks" Output :...
Read more >
Array methods
So, if we look for false , it finds exactly false and not the zero. If we want to check if item exists...
Read more >
What is A/B Testing? A Practical Guide With Examples
Implementing a change on your website without testing it may or may not pay ... by using research tools/methods like form analysis to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found