Mocking MatSnackBar in Angular 8 & Jasmine
问题 I have an Angular 8 application that uses the Angular Material MatSnackBar and I am trying to test that the open() method of the class is called. The call to the open() method is within the body of an NgRx store selector, like this: ngOnInit() { this.store.dispatch(fromStore.getFeaturedPlaylists()); this.subscription = this.store.pipe( select(fromStore.selectError), filter(err => !!err), switchMap((err) => this.snackBar.open( `Error: ${err.message}`, 'Try again', {duration: 5000})