Currently, I am working with this script:
groups: Group[] = []
constructor(
) {
this.groups = AuthenticationService.getUserGroups()
let menuList: any = []
this.groups.map((permission: Group) => {
menuList.push(...this.menuGenerator[permission.nomeGrupo.split('-')[1]])
})
}
However, when I execute npm run test
, I encounter an error message stating
TypeError: undefined is not an object (evaluating 'this.groups.map')
. I am seeking the best solution to resolve this issue. I attempted using spyOn
for getUserGroups
, but it did not work. How can I assign a value to the variable in this case? Thank you for your assistance! This situation is crucial for my understanding!