import(..) returns undefinded instead of results of resolution #155
-
When the The for loop does not return the results of the promises If we would use a map and return instead of the |
Beta Was this translation helpful? Give feedback.
Replies: 8 comments
-
This is the actual error message: The task returned undefined. You must return a promise, a value, or null to indicate that the task was handled. |
Beta Was this translation helpful? Give feedback.
-
So after some investigation I found the issue to be that this function does not return anything - so it returns undefined. https://github.com/pkosiec/mongo-seeding/blob/master/core/src/index.ts#L119 So if we add a |
Beta Was this translation helpful? Give feedback.
-
Hi @gerwinbrunner, thank you for your contribution! Yes, you're right - currently, the import function resolves with the
In this case Could you please elaborate a bit about the issues you encounter with using Thanks! |
Beta Was this translation helpful? Give feedback.
-
Sure! in cypress I define a task to seed the data:
Calling this task raises the error mentioned in a previous post. The data import is anyway done successfully before the error is raised. The return of the |
Beta Was this translation helpful? Give feedback.
-
I found a workaround for now without having to forge you library.
|
Beta Was this translation helpful? Give feedback.
-
@gerwinbrunner Yup, the workaround looks like it is the best approach here. I would only slightly modify the two ending lines for the function: await mongoSeeder.import(collections);
return true; It seems right to me - because this is specific requirement from Cypress. And as I wrote before, resolving promise with Do you feel convinced that this is not the issue of Mongo Seeding? 😄 If so, can we close this issue and PR? |
Beta Was this translation helpful? Give feedback.
-
Yeah, sure - the workaround is fine for me. |
Beta Was this translation helpful? Give feedback.
-
I wouldn't treat it as a workaround, but in this case as a proper solution 🙂 Anyway, thanks for the openness and good open source attitude 🙂 Cheers! |
Beta Was this translation helpful? Give feedback.
@gerwinbrunner Yup, the workaround looks like it is the best approach here. I would only slightly modify the two ending lines for the function:
It seems right to me - because this is specific requirement from Cypress. And as I wrote before, resolving promise with
undefined
is just as fine as returning from function withundefined
.Do you feel convinced that this is not the issue of Mongo Seeding? 😄 If so, can we close this issue and PR?