Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

124
Views
Nighwatch ignores await in tests

I'm trying to start with Nightwatch and faced the unclear behavior.

Please take a look at the the following code. I want to gather some text from a page into the list and then print it. Note the async test and await browser.perform call:

module.exports = {
    '@tags': ['smoke test'],
    'Work with a table': async browser => {
        browser.page.mainPage.tablePage().navigate();
        let list = []
        await browser
            .perform(function () {
                browser.elements('css selector', 'thead th', function (elements) {
                    elements.value.forEach(function (elementsObj, index) {
                        browser.elementIdText(elementsObj.ELEMENT, function (result) {
                            list.push(result.value)
                            console.log('>> ' + result.value);
                        })
                    })
                })
            })
        console.log('list: ' + list);
        console.log('end');
    }
}

In my understanding, I should see the result of console.log('list: ' + list) as a fulfilled list at the end of the test. But the output is:

\ Running Work with a table:
list:
| Running Work with a table:
>> Name
>> Position
>> Office
>> Age
>> Start date
‼ Running Work with a table:

No assertions ran.

So the console.log('list: ' + list); was executed before. What I'm doing wrong here?

Another one question is why the last console.log('end'); is not printed at all?

Update I tried to name the test as 'Work with a table': async function(browser), with the same result. And if I add the await keyword to the browser.page.mainPage.tablePage().navigate(); command, there is no console log printed at all.

Update2 The result of broser.perform is a Promise, enter image description here

When I print it, I get the following:

Promise {
  <pending>,
  capabilities: {
  acceptInsecureCerts: false,
  acceptSslCerts: false,
  applicationCacheEnabled: false,
  browserConnectionEnabled: false,
  . . . 
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!