angular-datatables icon indicating copy to clipboard operation
angular-datatables copied to clipboard

JQuery selector fails when running Jasmine test

Open brussonOC opened this issue 7 years ago • 2 comments

I'm submitting a...


[ ] Bug report  
[ ] Feature request
[ ] Documentation issue or request
[x] Question

Current behavior

I am using datatables in my Angular app which works fine but when a Jasmine test is run against the page it fails with the below error:

Uncaught TypeError: $(...).DataTable is not a function thrown

My markup calls a function which destroys the datatable to resolve the issue of getting the below message when performing multiple searches.

https://datatables.net/manual/tech-notes/3

The function my component.ts file to do that is:

destroyDataTable(): any { if (this.form.valid && this.hasSearchValueBeenEntered()) { const dt = $('#results-grid').DataTable(); if (dt) { dt.destroy(); } } }

This works fine when the application is run, however when a Jasmine test is run I get the below error.

Uncaught TypeError: $(...).DataTable is not a function

How do I resolve this so that the tests will run?

brussonOC avatar Feb 27 '19 10:02 brussonOC

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Dec 06 '20 13:12 stale[bot]

This issue has been closed due to inactivity. Please feel free to re-open the issue to add new inputs.

stale[bot] avatar Dec 13 '20 15:12 stale[bot]