I'm trying to test this component on vue, but when I run the test I get the message down bellow:
RangeError: Invalid array length
96 | this.changeLogs.marketConfiguration.productTypes
97 | );
> 98 | return [
| ^
99 | ...new Set(
100 | productTypes.flatMap((productType) => productType.domains || [])
101 | )
I'm using Jest, with vue-test-utils.
And this is the function:
affectedDomains(): string {
const productTypes: ProductTypeConfiguration[] = Object.values(
this.changeLogs.marketConfiguration.productTypes
);
return [
...new Set(
productTypes.flatMap((productType) => productType.domains || [])
)
].join(', ');
}
Found a solution, in my case was to set the "downlevelIteration": true,
on tsconfig.json
.
Downleveling is TypeScript’s term for transpiling to an older version of JavaScript. This flag is to enable support for a more accurate implementation of how modern JavaScript iterates through new concepts in older JavaScript runtimes.