2

I'm getting following error in ag-grid jest unit test in angular. Any idea what could be causing it?

TypeError: Cannot read property 'measureText' of null

  23 | import { assign, get, isEmpty } from 'lodash';
  24 | import {
> 25 |      a4aGridTypes,
  26 |      abbreviated,
  27 |      AbbreviatedColumn,
  28 |      columnTypes,

 at node_modules/ag-grid-enterprise/dist/lib/charts/canvas/hdpiCanvas.js:258:45
      at Object.<anonymous> (node_modules/ag-grid-enterprise/dist/lib/charts/canvas/hdpiCanvas.js:264:2)
      at Object.<anonymous> (node_modules/ag-grid-enterprise/dist/lib/charts/scene/scene.js:4:20)
      at Object.<anonymous> (node_modules/ag-grid-enterprise/dist/lib/charts/chart/chart.js:4:15)
      at Object.<anonymous> (node_modules/ag-grid-enterprise/dist/lib/charts/chart/cartesianChart.js:17:15)
      at Object.<anonymous> (node_modules/ag-grid-enterprise/dist/lib/charts/chart.js:31:24)
      at Object.<anonymous> (node_modules/ag-grid-enterprise/dist/lib/charts/chartingService.js:15:15)
      at Object.<anonymous> (node_modules/ag-grid-enterprise/dist/lib/menu/menuItemMapper.js:16:25)
      at Object.<anonymous> (node_modules/ag-grid-enterprise/dist/lib/menu/enterpriseMenu.js:29:24)
      at Object.<anonymous> (node_modules/ag-grid-enterprise/main.js:5:24)

I'm following the documentation from ag-grid: https://www.ag-grid.com/javascript-grid-testing-angular/ and using following versions:

"ag-grid-angular": "20.2.0",
    "ag-grid-community": "20.2.0",
    "ag-grid-enterprise": "20.2.0",
RV.
  • 2,781
  • 3
  • 29
  • 46

1 Answers1

2

According to the official documentation of ag-grid V21.0.0 under the key: AG-2869 an issue regarding jest has already have been addressed.

AG-2869: Error is thrown when Importing ag-grid-enterprise when running jest tests with ag-grid

Simply upgrading to a newer version of Ag-Grid may fix your current issue.

Update to following versions of the ag-grid library:

    "ag-grid-angular": "21.0.0",
    "ag-grid-community": "21.0.0",
    "ag-grid-enterprise": "21.0.0",
RV.
  • 2,781
  • 3
  • 29
  • 46
tsmi
  • 51
  • 1
  • 4