Im trying to create a basic jest test interacting with a npm dependency: react-diagrams
The failing test
import { DiagramModel } from '@projectstorm/react-diagrams'
test('importing react diagrams', () => {
let x = DiagramModel
});
Simply referencing the DiagramModel
class causes this error:
ReferenceError: self is not defined
> 1 | import { DiagramModel } from '@projectstorm/react-diagrams'
| ^
2 |
3 | test('importing react diagrams', () => {
4 | let x = DiagramModel
at Object.<anonymous> (node_modules/@projectstorm/react-diagrams/dist/index.umd.js:1:331)
at Object.<anonymous> (tests/DiagramModel.test.ts:1:1)
Other tests works fine, and the dependency works fine when bundeled elsewhere.
jest.config.js
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
};
package.json
"jest": "^26.6.3",
"ts-jest": "^26.5.2",
...
Any ideas what I can do to remedy this?
Reproducing
Added test + configuration in a codesandbox (but could not get the test runner to pick it up). The full repo