I am trying write tests for my javascript project that uses tabulator (^5.2.2)
using jest (v27)
. The tabulator is being imported and used in JS file like below
import {TabulatorFull as Tabulator} from "tabulator-tables";
...
var table = new Tabulator("#example-table", config)
...
When I run the project using webpack and load in browser, everything works fine, but when I try to run tests of the same file in jest, I get this error
FAIL tests/integration/__tests__/tabulator.js
● Test suite failed to run
TypeError: _tabulatorTables.TabulatorFull is not a constructor
15 |
16 |
> 17 | var table = new Tabulator("#example-table", {
| ^
18 | data:tabledata, //load row data from array
19 | layout:"fitColumns", //fit columns to width of table
20 | responsiveLayout:"hide", //hide columns that dont fit on the table
at Object.<anonymous> (src/main.js:17:13)
at Object.<anonymous> (tests/integration/__tests__/tabulator.js:1:1)
Test Suites: 1 failed, 1 total
Tests: 0 total
Snapshots: 0 total
Time: 0.703 s
Ran all test suites.
And when I change this import from above to below
import Tabulator from "tabulator-tables";
I no more see the above error but then there's no data rendered in the table even though I've checked in the tabulator's dataLoaded
event that data is loaded.
Would appreciate any kind of help, thanks!