ajthinking / data-story

A visual process builder

Home Page:https://datastory.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Jest fails with 'self is not defined' when importing react-diagrams

ajthinking opened this issue · comments

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)

Fixed with this jest.config.js:

module.exports = {
  preset: 'ts-jest',
  testEnvironment: 'jsdom',
};