I am trying to spread two arrays into one. In React, I am looping state array and in that loop for a particular value, I am updating with previous value with another value. But it is making unit test cases are freezing Here is the sample code:
const formValues = [...this.state.formValues];
formValues.forEach((item) => {
if(item.label === 'policy'){
const fieldPermissions = this.props.permissions;
item.value = [...item.value, ...fieldPermissions];
}
})
`
In the above code, I am spreading field emissions and item. value and assigning to item.value, UI is working as expected. But unit test cases are feezing, not running. On removing spreading of item.value, unit test cases are working. Tried different ways to figure it out like concat, array loop, push, etc. Can anyone help me with this?