Jest fails with 'self is not defined' when importing react-diagrams
ajthinking opened this issue · comments
Anders Jürisoo commented
tests/DiagramModel.test.ts
import { DiagramModel, NodeModelGenerics } from '@projectstorm/react-diagrams'
test('importing react diagrams', () => {
// Uncomment this to make test fail!
// DiagramModel
});
Throws
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)
Anders Jürisoo commented
Fixed with this jest.config.js:
module.exports = {
preset: 'ts-jest',
testEnvironment: 'jsdom',
};