//mockIndex.ts
//@ts-ignore
import {Document} from "flexsearch"
export const mockIndexData = async (config:IIndexConfig,documents:any[]) => {
const index = new Document(config)
for (const doc of documents) {
index.add(doc)
}
const data:Record<string,any> = {}
await Promise.all(index.export(function(key:string,value:any) {
data[key] = value
}))
return data
}
Logs
undefined is not iterable (cannot read property Symbol(Symbol.iterator))
TypeError: undefined is not iterable (cannot read property Symbol(Symbol.iterator))
at Function.all (<anonymous>)
at Object.mockIndexData (C:\Users\Samuel\Documents\GitHub\Type.io---Next\nuxt\src\Mocks\IndexMock\mockIndex.ts:54:16)
at C:\Users\Samuel\Documents\GitHub\Type.io---Next\nuxt\test\backend\Index\IndexLoader.spec.ts:64:45
at Promise.then.completed (C:\Users\Samuel\Documents\GitHub\Type.io---Next\nuxt\node_modules\jest-circus\build\utils.js:390:28)
at new Promise (<anonymous>)
at callAsyncCircusFn (C:\Users\Samuel\Documents\GitHub\Type.io---Next\nuxt\node_modules\jest-circus\build\utils.js:315:10)
at _callCircusHook (C:\Users\Samuel\Documents\GitHub\Type.io---Next\nuxt\node_modules\jest-circus\build\run.js:181:40)
at _runTestsForDescribeBlock (C:\Users\Samuel\Documents\GitHub\Type.io---Next\nuxt\node_modules\jest-circus\build\run.js:47:7)
at _runTestsForDescribeBlock (C:\Users\Samuel\Documents\GitHub\Type.io---Next\nuxt\node_modules\jest-circus\build\run.js:60:9)
at _runTestsForDescribeBlock (C:\Users\Samuel\Documents\GitHub\Type.io---Next\nuxt\node_modules\jest-circus\build\run.js:60:9)
Issue
When running index.export(handler) I get undefined is not iterable error.
Relevant Code
Logs