Quantcast
Channel: GoJS - Northwoods Software
Viewing all articles
Browse latest Browse all 7069

Using GoJS in unit tests

$
0
0

@tswistak wrote:

Hi,

Since GoJS 2.0 has support for browser-less environments like Node, I decided to incorporate some unit tests for our diagram handling functions. However, I am unable to use it - I get following error:

TypeError: Cannot set property ‘fillStyle’ of null
at node_modules/gojs/release/go.js:828:107
at Object. (node_modules/gojs/release/go.js:2076:265)

I’m running unit tests through Jest with TypeScript. Here’s the code of sample unit test using GoJS that doesn’t work:

import * as go from 'gojs';
const $ = go.GraphObject.make;
const myPalette = $(go.Palette, '', { viewSize: new go.Size(100, 100) });
const model = [
    { key: 'A', group: '' }
];
myPalette.model = new go.GraphLinksModel(model);    
describe('palette', () => {
    test('should have nodedataarray created from model', () => {
        expect(myPalette.model.nodeDataArray).toHaveLength(model.length);
    });
});

Do you have any idea why this error is thrown and what we can do to be able to use GoJS functionalities through Jest?

I’m using GoJS from NPM, version “2.0.0-beta6”. Version of Jest is “23.6.0”, and ts-jest “23.10.4”.

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 7069

Trending Articles