ngx-contextmenu icon indicating copy to clipboard operation
ngx-contextmenu copied to clipboard

Jasmine Testing Components w/ context-menu

Open dalexander-trc opened this issue 5 years ago • 1 comments

Describe the bug Jasmine tests fail for components that include context-menu tags in their HTML. I didn't see anything in the documentation describing how to handle this.

To Reproduce Steps to reproduce the behavior:

  1. Create a component and include a context-menu, any of the samples provided on the GitHub page will do.
  2. Attempt to run a jasmine test. You must include the ContextMenuService and ContextMenuModule to get past injection and binding errors, respectively.
  3. See error (simplified below, full stack is available at StackBlitz)

TypeError: Cannot read property 'show' of undefined ... at Jasmine at new ContextMenuComponent at createClass at createDirectiveInstance at createViewNodes at callViewAction . . .

Expected behavior Ideally if I wanted to test a context menu implementation I would put it in its own component and test it there. In this situation, I would prefer if the menu was ignored entirely as I intend to test only the functionality native to the component itself.

Stackblitz Example https://stackblitz.com/edit/ngx-contextmenu-example-b9cxub https://ngx-contextmenu-example-b9cxub.stackblitz.io

dalexander-trc avatar Aug 01 '19 14:08 dalexander-trc

In your stackblitz, I changed:

providers: [ {provide: ContextMenuService }]

to:

providers: [ ContextMenuService ]

and seems to work fine

jarodsmk avatar Nov 28 '19 11:11 jarodsmk