-
Notifications
You must be signed in to change notification settings - Fork 2k
/
node.js
34 lines (28 loc) · 1.11 KB
/
node.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
require('reify');
// Polyfill for loaders
// TODO - @loaders.gl/polyfills seems to freeze the tests
global.fetch = () => Promise.reject('fetch not available in node');
// Polyfill with JSDOM
const {JSDOM} = require('jsdom');
const dom = new JSDOM(`<!DOCTYPE html>`);
// These globals are required by @jupyter-widgets/base
/* global global */
global.window = dom.window;
global.navigator = dom.window.navigator;
global.document = dom.window.document;
global.Element = dom.window.Element;
global.__JSDOM__ = true;
global.Image = dom.window.Image;
global.HTMLCanvasElement = dom.window.HTMLCanvasElement;
global.HTMLVideoElement = dom.window.HTMLVideoElement;
const moduleAlias = require('module-alias');
moduleAlias.addAlias('@jupyter-widgets/base', (fromPath, request, alias) => {
return `${__dirname}/modules/jupyter-widget/mock-widget-base.js`;
});
const {gl} = require('@deck.gl/test-utils');
// Create a dummy canvas for the headless gl context
const canvas = global.document.createElement('canvas');
canvas.width = gl.drawingBufferWidth;
canvas.height = gl.drawingBufferHeight;
gl.canvas = canvas;
require('./modules');