Error: describe expects a function argument; received [object AsyncFunction]

1,117 views
Skip to first unread message

Ish Abbi

unread,
Dec 11, 2018, 11:48:05 AM12/11/18
to Jasmine
Hi,

I'm trying to run my tests against a data set which is defined as a json. The approach works when I try to use it for the it method. But when I try to do the same for the describe method I get the below exception :

[chrome #11] *(node:10701) UnhandledPromiseRejectionWarning: Error: describe expects a function argument; received [object AsyncFunction]

[chrome #11]     at ensureIsFunction (/usr/local/lib/node_modules/protractor/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:1041:15)

[chrome #11]     at Env.describe (/usr/local/lib/node_modules/protractor/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:1066:7)

[chrome #11]     at describe (/usr/local/lib/node_modules/protractor/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:4399:18)

[chrome #11]     at /Users/ishabbi/AirAsiaHomePageAutomation/homepageautomation/spec/ui/homePageGeneralOps.spec.js:16:11

[chrome #11]     at Array.forEach (<anonymous>)

[chrome #11]     at Object.<anonymous> (/Users/ishabbi/AirAsiaHomePageAutomation/homepageautomation/spec/ui/homePageGeneralOps.spec.js:15:22)

[chrome #11]     at Module._compile (internal/modules/cjs/loader.js:688:30)

[chrome #11]     at loader (/Users/ishabbi/AirAsiaHomePageAutomation/homepageautomation/node_modules/babel-register/lib/node.js:144:5)

[chrome #11]     at Object.require.extensions.(anonymous function) [as .js] (/Users/ishabbi/AirAsiaHomePageAutomation/homepageautomation/node_modules/babel-register/lib/node.js:154:7)

[chrome #11]     at Module.load (internal/modules/cjs/loader.js:598:32)


Below is the code snippet :

homePageDataProvider.forEach(async (culture) => {
   await describe('Test Suite ' + culture.locale + ' Culture', async () => {
       beforeEach(async () =>  {
           await homePageActions.goToUrl(culture.locale);
           await homePageActions.selectCulture(culture.locale);
       });

        culture.universalHeader.forEach((obj) => {
           it('Validate header option : ' + obj.text, async () => {
               await homePageActions.clickHeaderOption(obj);
           })
       });
   });
});

Anything that can be done?

Thanks,
Ish

Gregg Van Hove

unread,
Dec 11, 2018, 8:38:44 PM12/11/18
to jasmi...@googlegroups.com
The `describe` function in Jasmine does not support asynchronous callbacks (in any form). It doesn't look like you're actually using `await` in that function though, so you might be able to just remove the `async` keyword in your call to describe.

Hope this helps. Thanks for using Jasmine!

- Gregg

--
You received this message because you are subscribed to the Google Groups "Jasmine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jasmine-js+...@googlegroups.com.
To post to this group, send email to jasmi...@googlegroups.com.
Visit this group at https://groups.google.com/group/jasmine-js.
For more options, visit https://groups.google.com/d/optout.

Ish Abbi

unread,
Dec 12, 2018, 10:19:33 PM12/12/18
to jasmi...@googlegroups.com
Thank you Gregg for the clarification. :-)
Reply all
Reply to author
Forward
0 new messages