@kitware/vtk.js + Jest = Cannot use import statement outside a module

Update I got it working with the following changes

1- Using the jsdom test environment, and importing using the full path

/**
 * @jest-environment jsdom
 */
import vtkXMLImageDataReader from '@kitware/vtk.js/IO/XML/XMLImageDataReader.js';

test('mytest', done => {
  console.log('My test has been called')
  done();
});

I could not get it to import from just @kitware/vtk.js

2- Changing .babelrc to babel.config.json.

I expect there is a better or more ellegant solution though.

1 Like