JQuery selector fails when running Jasmine test
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?
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.
This issue has been closed due to inactivity. Please feel free to re-open the issue to add new inputs.