Skip to content
This repository was archived by the owner on Jul 29, 2024. It is now read-only.
This repository was archived by the owner on Jul 29, 2024. It is now read-only.

async / await not working due to jasminewd2  #4186

@th3l0g4n

Description

@th3l0g4n

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions