return Promise.mapSeries(_.times(lineCount(reader)), i => {
let dbFilter = { RefNumber : i }
return expectData.dbDataExpected(dbCollection, dbFilter)
.then(() => {
console.log("Data: ", expectData.dataDB)
})
})
The above code is from cucumber step definition! WHen I run the test I receive the following error:
Error: function uses multiple asynchronous interfaces: callback and promise to use the callback interface: do not return a promise to use the promise interface: remove the last argument to the function
Do you have any idea why i got this error?
return Promise.mapSeries(_.times(lineCount(reader)), i => {
let dbFilter = { RefNumber : i }
return expectData.dbDataExpected(dbCollection, dbFilter)
.then(() => {
console.log("Data: ", expectData.dataDB)
})
})
The above code is from cucumber step definition! WHen I run the test I receive the following error:
Error: function uses multiple asynchronous interfaces: callback and promise to use the callback interface: do not return a promise to use the promise interface: remove the last argument to the function
Do you have any idea why i got this error?
Share Improve this question edited Apr 16, 2021 at 5:53 Raul_M asked Apr 14, 2021 at 6:39 Raul_MRaul_M 2911 gold badge3 silver badges12 bronze badges 3- You are trying to return a promise (.then()) from a promise, try returning a value in your .then – cyw Commented Apr 14, 2021 at 6:44
- I updated the description with the function dbDataExpected which get data from mongo! how should I proceed in this case? – Raul_M Commented Apr 14, 2021 at 6:54
- You should probably initialize a variable outside of your .then, set the data from the .then to the variable on the outside, then return that variable instead of returning the .then(), when you return the .then() you are returning a promise, but by setting the variable on the outside, you are returning your data. – cyw Commented Apr 14, 2021 at 7:06
1 Answer
Reset to default 22When implement a step definitions in case if you have more parameters than those defined in the scenario, then you will receive this Error.
Eq.
Scenario: When the user creates "car1" and "car2"
Step definition:
When('the user creates {string} and {string}',function(p1:string, p2:string, p3:string){
...
})