Vue + Jest. Юнит тест падает с ошибкой `forEach is not a function`
Стек: Nuxt, Jest
Внутри функции matchCategoryBrands() я прохожусь по массиву catalogCategoriesIncluded через forEach
matchCategoryBrands() {
this.categoryBrands = []
this.catalogCategoriesIncluded.forEach(included => {
this.categoryBrandsRelationships.forEach(brand => {
if (included.id === brand.id) {
this.categoryBrands.push(included.attributes)
}
})
})
}
Ниже кусок кода с юнит-тестом для функции matchCategoryBrands()
test('получить рубрики по бренду', () => {
wrapper.vm.matchCategoryBrands()
expect(wrapper.vm.catalogCategoriesIncluded).toBeInstanceOf(Array)
})
При прогоне юнит-тестов, этот падает с ошибкой
component (Catalog): тест каталога товаров › получить рубрики по бренду
TypeError: this.catalogCategoriesIncluded.forEach is not a function
365 | }
366 |
> 367 | this.catalogCategoriesIncluded.forEach(included => {
| ^
368 | this.categoryBrandsRelationships.forEach(brand => {
369 | if (included.id === brand.id) {
370 | this.categoryBrands.push(included.attributes)
Подскажите, что можно сделать в этой ситуации?
Может, нужно замокать catalogCategoriesIncluded?