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.

async / await not working due to jasminewd2

See original GitHub issue

I`m trying to use protractor with plain nodejs (not Typescript) and async functions as test callbacks. Unfortunately an error appears telling me that these async functions are no functions.

Stacktrace:

1) some test encountered a declaration exception
  Message:
    Error: async function() {
        await browser.get('https://www.google.com');
    });
} is not a function
  Stack:
    Error: async function () {
            await browser.get('https://www.sixt-neuwagen.de');
    
            let blub = await ekomi.isDisplayed();
            expect(blub).toBe(true);
        } is not a function
        at validateFunction (/<some>/<path>/projects/protractor/node_modules/jasminewd2/index.js:21:11)
        at /<some>/<path>/projects/protractor/node_modules/jasminewd2/index.js:139:16
        at Suite.<anonymous> (/<some>/<path>/projects/protractor/specs/index.js:5:5)
        at Object.<anonymous> (/<some>/<path>/projects/protractor/specs/index.js:2:1)
        at Module._compile (module.js:571:32)
        at Object.Module._extensions..js (module.js:580:10)
        at Module.load (module.js:488:32)

Testsuite:

describe('some test', function() {
    it('should do something', async function() {
        await browser.get('https://www.google.com');
    });
});

Reason: (Taken from jasminewd2 index.js)

function validateFunction(functionToValidate) {
  if (functionToValidate && Object.prototype.toString.call(functionToValidate) === '[object Function]') {
    return functionToValidate;
  } else {
    throw Error(functionToValidate + ' is not a function');
  }
}

Async functions checked with Object.prototype.toString.call(functionToValidate) evaluate to [object AsyncFunction].

Env:

  • Node Version: 7.7.1
  • Protractor Version: 5.1.1
  • jasminewd2 Version: 2.0.0

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:13 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
alexeyraspopovcommented, Apr 18, 2017

@heathkit, I was able to use async/await (without Babel) in my protractor tests after applying angular/jasminewd#87

1reaction
heathkitcommented, Apr 18, 2017

Thanks for the fix! I’ll take a look.

Read more comments on GitHub >

github_iconTop Results From Across the Web

protractor async await not a function - Stack Overflow
I meet the same issue with nodejs 7.9 + protractor 5.1.1. This is an issue in jasminewd2, and still open, see the following...
Read more >
jasminewd2 - npm
Automatically makes tests asynchronously wait until the WebDriverJS control flow is empty. If a done function is passed to the test, waits for ......
Read more >
jasminewd2 | Yarn - Package Manager
Automatically makes tests asynchronously wait until the WebDriverJS control flow is empty. If a done function is passed to the test, waits for...
Read more >
async function - JavaScript - MDN Web Docs - Mozilla
The async function declaration declares an async function where the await keyword is permitted within the function body. The async and await ......
Read more >
Async Await Feature In Angular - StackBlitz
Run `ng serve` for a dev server. Navigate to. `http://localhost:4200/`. The app will. automatically reload if you change any of the. source files....
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