@luma.gl/test-utils 8.5.10 → 8.6.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/dist/context.d.ts +3 -0
  2. package/dist/context.d.ts.map +1 -0
  3. package/dist/{esm/context.js → context.js} +1 -4
  4. package/dist/context.js.map +1 -0
  5. package/dist/create-headless-context.d.ts +2 -0
  6. package/dist/create-headless-context.d.ts.map +1 -0
  7. package/dist/create-headless-context.js +37 -0
  8. package/dist/create-headless-context.js.map +1 -0
  9. package/dist/create-test-context.d.ts +2 -0
  10. package/dist/create-test-context.d.ts.map +1 -0
  11. package/dist/create-test-context.js +16 -0
  12. package/dist/create-test-context.js.map +1 -0
  13. package/dist/index.d.ts +5 -0
  14. package/dist/index.d.ts.map +1 -0
  15. package/dist/index.js +5 -0
  16. package/dist/index.js.map +1 -0
  17. package/dist/performance-test-runner.d.ts +10 -0
  18. package/dist/performance-test-runner.d.ts.map +1 -0
  19. package/dist/{esm/performance-test-runner.js → performance-test-runner.js} +6 -0
  20. package/dist/performance-test-runner.js.map +1 -0
  21. package/dist/snapshot-test-runner.d.ts +9 -0
  22. package/dist/snapshot-test-runner.d.ts.map +1 -0
  23. package/dist/{esm/snapshot-test-runner.js → snapshot-test-runner.js} +5 -1
  24. package/dist/snapshot-test-runner.js.map +1 -0
  25. package/dist/test-runner.d.ts +45 -0
  26. package/dist/test-runner.d.ts.map +1 -0
  27. package/dist/{esm/test-runner.js → test-runner.js} +16 -7
  28. package/dist/test-runner.js.map +1 -0
  29. package/dist/utils.d.ts +7 -0
  30. package/dist/utils.d.ts.map +1 -0
  31. package/dist/{esm/utils.js → utils.js} +0 -0
  32. package/dist/utils.js.map +1 -0
  33. package/package.json +8 -5
  34. package/src/{context.js → context.ts} +3 -2
  35. package/src/create-headless-context.ts +36 -0
  36. package/src/create-test-context.ts +20 -0
  37. package/{dist/esm/index.d.ts → src/index.ts} +2 -1
  38. package/src/{performance-test-runner.js → performance-test-runner.ts} +6 -3
  39. package/src/{snapshot-test-runner.js → snapshot-test-runner.ts} +6 -3
  40. package/src/{test-runner.js → test-runner.ts} +41 -17
  41. package/src/{utils.js → utils.ts} +0 -0
  42. package/dist/es5/context.d.ts +0 -4
  43. package/dist/es5/context.js +0 -65
  44. package/dist/es5/context.js.map +0 -1
  45. package/dist/es5/index.d.ts +0 -3
  46. package/dist/es5/index.js +0 -38
  47. package/dist/es5/index.js.map +0 -1
  48. package/dist/es5/performance-test-runner.d.ts +0 -5
  49. package/dist/es5/performance-test-runner.js +0 -96
  50. package/dist/es5/performance-test-runner.js.map +0 -1
  51. package/dist/es5/snapshot-test-runner.d.ts +0 -5
  52. package/dist/es5/snapshot-test-runner.js +0 -89
  53. package/dist/es5/snapshot-test-runner.js.map +0 -1
  54. package/dist/es5/test-runner.d.ts +0 -45
  55. package/dist/es5/test-runner.js +0 -239
  56. package/dist/es5/test-runner.js.map +0 -1
  57. package/dist/es5/utils.js +0 -17
  58. package/dist/es5/utils.js.map +0 -1
  59. package/dist/esm/context.d.ts +0 -4
  60. package/dist/esm/context.js.map +0 -1
  61. package/dist/esm/index.js +0 -4
  62. package/dist/esm/index.js.map +0 -1
  63. package/dist/esm/performance-test-runner.d.ts +0 -5
  64. package/dist/esm/performance-test-runner.js.map +0 -1
  65. package/dist/esm/snapshot-test-runner.d.ts +0 -5
  66. package/dist/esm/snapshot-test-runner.js.map +0 -1
  67. package/dist/esm/test-runner.d.ts +0 -45
  68. package/dist/esm/test-runner.js.map +0 -1
  69. package/dist/esm/utils.js.map +0 -1
  70. package/src/context.d.ts +0 -4
  71. package/src/index.d.ts +0 -3
  72. package/src/index.js +0 -3
  73. package/src/performance-test-runner.d.ts +0 -5
  74. package/src/snapshot-test-runner.d.ts +0 -5
  75. package/src/test-runner.d.ts +0 -45
@@ -0,0 +1,3 @@
1
+ export declare function createTestContext(opts?: {}): WebGLRenderingContext;
2
+ export declare function createHeadlessContext(options?: any): WebGLRenderingContext;
3
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAkBA,wBAAgB,iBAAiB,CAAC,IAAI,KAAK,GAAG,qBAAqB,CAMlE;AAID,wBAAgB,qBAAqB,CAAC,OAAO,CAAC,EAAE,GAAG,GAAG,qBAAqB,CAkB1E"}
@@ -1,10 +1,7 @@
1
1
  import { createGLContext, instrumentGLContext } from '@luma.gl/gltools';
2
2
  import { isBrowser } from 'probe.gl/env';
3
3
  const ERR_HEADLESSGL_FAILED = 'Failed to create WebGL context in Node.js, headless gl returned null';
4
- const ERR_HEADLESSGL_LOAD = `\
5
- luma.gl: loaded under Node.js without headless gl installed, meaning that WebGL \
6
- contexts can not be created. This may not be an error. For example, this is a \
7
- typical configuration for isorender applications running on the server.`;
4
+ const ERR_HEADLESSGL_LOAD = " luma.gl: loaded under Node.js without headless gl installed, meaning that WebGL contexts can not be created. This may not be an error. For example, this is a typical configuration for isorender applications running on the server.";
8
5
  const CONTEXT_DEFAULTS = {
9
6
  width: 1,
10
7
  height: 1,
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/context.ts"],"names":["createGLContext","instrumentGLContext","isBrowser","ERR_HEADLESSGL_FAILED","ERR_HEADLESSGL_LOAD","CONTEXT_DEFAULTS","width","height","debug","throwOnError","createTestContext","opts","Object","assign","context","createHeadlessContext","options","webgl1","webgl2","onError","message","Error","gl","headlessGL","args","headless","module","require"],"mappings":"AAAA,SAAQA,eAAR,EAAyBC,mBAAzB,QAAmD,kBAAnD;AACA,SAAQC,SAAR,QAAwB,cAAxB;AAEA,MAAMC,qBAAqB,GACzB,sEADF;AAGA,MAAMC,mBAAmB,gPAAzB;AAKA,MAAMC,gBAAgB,GAAG;AACvBC,EAAAA,KAAK,EAAE,CADgB;AAEvBC,EAAAA,MAAM,EAAE,CAFe;AAGvBC,EAAAA,KAAK,EAAE,IAHgB;AAIv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\nimport {isBrowser} from 'probe.gl/env';\n\nconst ERR_HEADLESSGL_FAILED =\n 'Failed to create WebGL context in Node.js, headless gl returned null';\n\nconst ERR_HEADLESSGL_LOAD = `\\\n luma.gl: loaded under Node.js without headless gl installed, meaning that WebGL \\\n contexts can not be created. This may not be an error. For example, this is a \\\n typical configuration for isorender applications running on the server.`;\n\nconst CONTEXT_DEFAULTS = {\n width: 1,\n height: 1,\n debug: true,\n throwOnError: false\n};\n\nexport function createTestContext(opts = {}): WebGLRenderingContext {\n opts = Object.assign({}, CONTEXT_DEFAULTS, opts);\n const context = isBrowser()\n ? createGLContext(opts)\n : instrumentGLContext(createHeadlessContext(opts), opts);\n return context;\n}\n\n// Create headless gl context (for running under Node.js)\n// Create headless gl context (for running under Node.js)\nexport function createHeadlessContext(options?: any): WebGLRenderingContext {\n const {width, height, webgl1, webgl2} = options;\n\n function onError(message) {\n if (options.throwOnError) {\n throw new Error(message);\n }\n return null;\n }\n\n if (webgl2 && !webgl1) {\n return onError('headless-gl does not support WebGL2');\n }\n const gl = headlessGL(width, height, options);\n if (!gl) {\n return onError(ERR_HEADLESSGL_FAILED);\n }\n return gl;\n}\n\n// Load headless gl dynamically, if available\nfunction headlessGL(...args) {\n const headless = module.require('gl');\n if (!headless) {\n throw new Error(ERR_HEADLESSGL_LOAD);\n }\n return headless(...args);\n}\n"],"file":"context.js"}
@@ -0,0 +1,2 @@
1
+ export declare function createHeadlessContext(options?: any): WebGLRenderingContext;
2
+ //# sourceMappingURL=create-headless-context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-headless-context.d.ts","sourceRoot":"","sources":["../src/create-headless-context.ts"],"names":[],"mappings":"AAmBA,wBAAgB,qBAAqB,CAAC,OAAO,CAAC,EAAE,GAAG,GAAG,qBAAqB,CAgB1E"}
@@ -0,0 +1,37 @@
1
+ import headlessGL from 'gl';
2
+ const ERR_HEADLESSGL_FAILED = 'Failed to create WebGL context in Node.js, headless gl returned null';
3
+ const ERR_HEADLESSGL_LOAD = " luma.gl: loaded under Node.js without headless gl installed, meaning that WebGL contexts can not be created. This may not be an error. For example, this is a typical configuration for isorender applications running on the server.";
4
+ const CONTEXT_DEFAULTS = {
5
+ width: 1,
6
+ height: 1,
7
+ debug: true,
8
+ throwOnError: false
9
+ };
10
+ export function createHeadlessContext(options) {
11
+ options = { ...CONTEXT_DEFAULTS,
12
+ ...options
13
+ };
14
+ const {
15
+ width,
16
+ height,
17
+ webgl1,
18
+ webgl2
19
+ } = options;
20
+
21
+ if (webgl2 && !webgl1) {
22
+ throw new Error('headless-gl does not support WebGL2');
23
+ }
24
+
25
+ if (!headlessGL) {
26
+ throw new Error(ERR_HEADLESSGL_LOAD);
27
+ }
28
+
29
+ const gl = headlessGL(width, height, options);
30
+
31
+ if (!gl) {
32
+ throw new Error(ERR_HEADLESSGL_FAILED);
33
+ }
34
+
35
+ return gl;
36
+ }
37
+ //# sourceMappingURL=create-headless-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/create-headless-context.ts"],"names":["headlessGL","ERR_HEADLESSGL_FAILED","ERR_HEADLESSGL_LOAD","CONTEXT_DEFAULTS","width","height","debug","throwOnError","createHeadlessContext","options","webgl1","webgl2","Error","gl"],"mappings":"AAAA,OAAOA,UAAP,MAAuB,IAAvB;AAEA,MAAMC,qBAAqB,GACzB,sEADF;AAGA,MAAMC,mBAAmB,gPAAzB;AAKA,MAAMC,gBAAgB,GAAG;AACvBC,EAAAA,KAAK,EAAE,CADgB;AAEvBC,EAAAA,MAAM,EAAE,CAFe;AAGvBC,EAAAA,KAAK,EAAE,IAHgB;AAIvBC,EAAAA,YAAY,EAAE;AAJS,CAAzB;AASA,OAAO,SAASC,qBAAT,CAA+BC,OAA/B,EAAqE;AAC1EA,EAAAA,OAAO,GAAG,EAAC,GAAGN,gBAAJ;AAAsB,OAAGM;AAAzB,GAAV;AAEA,QAAM;AAACL,IAAAA,KAAD;AAAQC,IAAAA,MAAR;AAAgBK,IAAAA,MAAhB;AAAwBC,IAAAA;AAAxB,MAAkCF,OAAxC;;AAEA,MAAIE,MAAM,IAAI,CAACD,MAAf,EAAuB;AACrB,UAAM,IAAIE,KAAJ,CAAU,qCAAV,CAAN;AACD;;AACD,MAAI,CAACZ,UAAL,EAAiB;AACf,UAAM,IAAIY,KAAJ,CAAUV,mBAAV,CAAN;AACD;;AACD,QAAMW,EAAE,GAAGb,UAAU,CAACI,KAAD,EAAQC,MAAR,EAAgBI,OAAhB,CAArB;;AACA,MAAI,CAACI,EAAL,EAAS;AACP,UAAM,IAAID,KAAJ,CAAUX,qBAAV,CAAN;AACD;;AACD,SAAOY,EAAP;AACD","sourcesContent":["import headlessGL from 'gl';\n\nconst ERR_HEADLESSGL_FAILED =\n 'Failed to create WebGL context in Node.js, headless gl returned null';\n\nconst ERR_HEADLESSGL_LOAD = `\\\n luma.gl: loaded under Node.js without headless gl installed, meaning that WebGL \\\n contexts can not be created. This may not be an error. For example, this is a \\\n typical configuration for isorender applications running on the server.`;\n\nconst CONTEXT_DEFAULTS = {\n width: 1,\n height: 1,\n debug: true,\n throwOnError: false\n};\n\n// Create headless gl context (for running under Node.js)\n// Create headless gl context (for running under Node.js)\nexport function createHeadlessContext(options?: any): WebGLRenderingContext {\n options = {...CONTEXT_DEFAULTS, ...options};\n\n const {width, height, webgl1, webgl2} = options;\n\n if (webgl2 && !webgl1) {\n throw new Error('headless-gl does not support WebGL2');\n }\n if (!headlessGL) {\n throw new Error(ERR_HEADLESSGL_LOAD);\n }\n const gl = headlessGL(width, height, options);\n if (!gl) {\n throw new Error(ERR_HEADLESSGL_FAILED);\n }\n return gl;\n}\n"],"file":"create-headless-context.js"}
@@ -0,0 +1,2 @@
1
+ export declare function createTestContext(opts?: Record<string, any>): WebGLRenderingContext | null;
2
+ //# sourceMappingURL=create-test-context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-test-context.d.ts","sourceRoot":"","sources":["../src/create-test-context.ts"],"names":[],"mappings":"AAIA,wBAAgB,iBAAiB,CAAC,IAAI,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,GAAG,qBAAqB,GAAG,IAAI,CAe9F"}
@@ -0,0 +1,16 @@
1
+ import { isBrowser } from 'probe.gl/env';
2
+ import { createGLContext, instrumentGLContext } from '@luma.gl/gltools';
3
+ import { createHeadlessContext } from './create-headless-context';
4
+ export function createTestContext(opts = {}) {
5
+ if (!isBrowser()) {
6
+ if (opts.webgl2 && !opts.webgl1) {
7
+ return null;
8
+ }
9
+
10
+ const gl = createHeadlessContext(opts);
11
+ return gl ? instrumentGLContext(gl) : null;
12
+ }
13
+
14
+ return createGLContext(opts);
15
+ }
16
+ //# sourceMappingURL=create-test-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/create-test-context.ts"],"names":["isBrowser","createGLContext","instrumentGLContext","createHeadlessContext","createTestContext","opts","webgl2","webgl1","gl"],"mappings":"AAAA,SAAQA,SAAR,QAAwB,cAAxB;AACA,SAAQC,eAAR,EAAyBC,mBAAzB,QAAmD,kBAAnD;AACA,SAASC,qBAAT,QAAsC,2BAAtC;AAEA,OAAO,SAASC,iBAAT,CAA2BC,IAAyB,GAAG,EAAvD,EAAyF;AAE5F,MAAI,CAACL,SAAS,EAAd,EAAkB;AAChB,QAAIK,IAAI,CAACC,MAAL,IAAe,CAACD,IAAI,CAACE,MAAzB,EAAiC;AAC/B,aAAO,IAAP;AACD;;AACD,UAAMC,EAAE,GAAGL,qBAAqB,CAACE,IAAD,CAAhC;AACA,WAAOG,EAAE,GAAGN,mBAAmB,CAACM,EAAD,CAAtB,GAA6B,IAAtC;AACD;;AACD,SAAOP,eAAe,CAACI,IAAD,CAAtB;AAMH","sourcesContent":["import {isBrowser} from 'probe.gl/env';\nimport {createGLContext, instrumentGLContext} from '@luma.gl/gltools';\nimport { createHeadlessContext } from './create-headless-context';\n\nexport function createTestContext(opts: Record<string, any> = {}): WebGLRenderingContext | null {\n // try {\n if (!isBrowser()) {\n if (opts.webgl2 && !opts.webgl1) {\n return null;\n }\n const gl = createHeadlessContext(opts);\n return gl ? instrumentGLContext(gl) : null;\n }\n return createGLContext(opts);\n // } catch {\n // if (opts.webgl2) {\n // return null;\n // }\n // }\n}\n"],"file":"create-test-context.js"}
@@ -0,0 +1,5 @@
1
+ export { default as SnapshotTestRunner } from './snapshot-test-runner';
2
+ export { default as PerformanceTestRunner } from './performance-test-runner';
3
+ export { createHeadlessContext } from './create-headless-context';
4
+ export { createTestContext } from './create-test-context';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,IAAI,kBAAkB,EAAC,MAAM,wBAAwB,CAAC;AACrE,OAAO,EAAC,OAAO,IAAI,qBAAqB,EAAC,MAAM,2BAA2B,CAAC;AAC3E,OAAO,EAAC,qBAAqB,EAAC,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAC,iBAAiB,EAAC,MAAM,uBAAuB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ export { default as SnapshotTestRunner } from './snapshot-test-runner';
2
+ export { default as PerformanceTestRunner } from './performance-test-runner';
3
+ export { createHeadlessContext } from './create-headless-context';
4
+ export { createTestContext } from './create-test-context';
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"names":["default","SnapshotTestRunner","PerformanceTestRunner","createHeadlessContext","createTestContext"],"mappings":"AAAA,SAAQA,OAAO,IAAIC,kBAAnB,QAA4C,wBAA5C;AACA,SAAQD,OAAO,IAAIE,qBAAnB,QAA+C,2BAA/C;AACA,SAAQC,qBAAR,QAAoC,2BAApC;AACA,SAAQC,iBAAR,QAAgC,uBAAhC","sourcesContent":["export {default as SnapshotTestRunner} from './snapshot-test-runner';\nexport {default as PerformanceTestRunner} from './performance-test-runner';\nexport {createHeadlessContext} from './create-headless-context';\nexport {createTestContext} from './create-test-context';\n"],"file":"index.js"}
@@ -0,0 +1,10 @@
1
+ import TestRunner, { TestRunnerOptions } from './test-runner';
2
+ export default class PerformanceTestRunner extends TestRunner {
3
+ private _stats;
4
+ private _fps;
5
+ constructor(props: TestRunnerOptions);
6
+ initTestCase(testCase: any): void;
7
+ shouldRender(animationProps: any): boolean;
8
+ assert(testCase: any): void;
9
+ }
10
+ //# sourceMappingURL=performance-test-runner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"performance-test-runner.d.ts","sourceRoot":"","sources":["../src/performance-test-runner.ts"],"names":[],"mappings":"AACA,OAAO,UAAU,EAAE,EAAC,iBAAiB,EAAC,MAAM,eAAe,CAAC;AAE5D,MAAM,CAAC,OAAO,OAAO,qBAAsB,SAAQ,UAAU;IAC3D,OAAO,CAAC,MAAM,CAAQ;IACtB,OAAO,CAAC,IAAI,CAAO;gBAEP,KAAK,EAAE,iBAAiB;IASpC,YAAY,CAAC,QAAQ,KAAA;IAMrB,YAAY,CAAC,cAAc,KAAA;IAY3B,MAAM,CAAC,QAAQ,KAAA;CAahB"}
@@ -1,8 +1,14 @@
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
1
2
  import { Stats } from 'probe.gl';
2
3
  import TestRunner from './test-runner';
3
4
  export default class PerformanceTestRunner extends TestRunner {
4
5
  constructor(props) {
5
6
  super(props);
7
+
8
+ _defineProperty(this, "_stats", void 0);
9
+
10
+ _defineProperty(this, "_fps", void 0);
11
+
6
12
  Object.assign(this.testOptions, {
7
13
  maxFramesToRender: 60,
8
14
  targetFPS: 50
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/performance-test-runner.ts"],"names":["Stats","TestRunner","PerformanceTestRunner","constructor","props","Object","assign","testOptions","maxFramesToRender","targetFPS","initTestCase","testCase","_stats","id","name","_fps","get","shouldRender","animationProps","timeEnd","timeStart","count","done","assert","fps","getHz","_pass","framesRendered","_fail","_next"],"mappings":";AAAA,SAAQA,KAAR,QA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AA,GAAD;AAAMG,QAAAA,cAAc,EAAEN;AAAtB,OAAX;AACD;;AACD,SAAKQ,KAAL;AACD;;AA3C2D","sourcesContent":["import {Stats, Stat} from 'probe.gl';\nimport TestRunner, {TestRunnerOptions} from './test-runner';\n\nexport default class PerformanceTestRunner extends TestRunner {\n private _stats: Stats;\n private _fps: Stat;\n\n constructor(props: TestRunnerOptions) {\n super(props);\n\n Object.assign(this.testOptions, {\n maxFramesToRender: 60,\n targetFPS: 50\n });\n }\n\n initTestCase(testCase) {\n super.initTestCase(testCase);\n this._stats = new Stats({id: testCase.name});\n this._fps = this._stats.get('fps');\n }\n\n shouldRender(animationProps) {\n this._fps.timeEnd();\n this._fps.timeStart();\n\n // @ts-ignore\n if (this._fps.count > this.testOptions.maxFramesToRender) {\n animationProps.done();\n }\n\n return true;\n }\n\n assert(testCase) {\n // @ts-ignore\n const targetFPS = testCase.targetFPS || this.testOptions.targetFPS;\n const count = this._fps.count;\n const fps = this._fps.getHz();\n\n if (fps >= targetFPS) {\n this._pass({fps, framesRendered: count});\n } else {\n this._fail({fps, framesRendered: count});\n }\n this._next();\n }\n}\n"],"file":"performance-test-runner.js"}
@@ -0,0 +1,9 @@
1
+ import TestRunner, { TestRunnerOptions } from './test-runner';
2
+ export default class SnapshotTestRunner extends TestRunner {
3
+ private isDiffing;
4
+ constructor(props: TestRunnerOptions);
5
+ initTestCase(testCase: any): void;
6
+ shouldRender(): boolean;
7
+ assert(testCase: any): void;
8
+ }
9
+ //# sourceMappingURL=snapshot-test-runner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"snapshot-test-runner.d.ts","sourceRoot":"","sources":["../src/snapshot-test-runner.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,EAAE,EAAC,iBAAiB,EAAC,MAAM,eAAe,CAAC;AAI5D,MAAM,CAAC,OAAO,OAAO,kBAAmB,SAAQ,UAAU;IACxD,OAAO,CAAC,SAAS,CAAkB;gBAEvB,KAAK,EAAE,iBAAiB;IAOpC,YAAY,CAAC,QAAQ,KAAA;IAOrB,YAAY;IAKZ,MAAM,CAAC,QAAQ,KAAA;CAiChB"}
@@ -1,8 +1,12 @@
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
1
2
  import TestRunner from './test-runner';
2
3
  import { getBoundingBoxInPage } from './utils';
3
4
  export default class SnapshotTestRunner extends TestRunner {
4
5
  constructor(props) {
5
6
  super(props);
7
+
8
+ _defineProperty(this, "isDiffing", false);
9
+
6
10
  this.testOptions.imageDiffOptions = {};
7
11
  }
8
12
 
@@ -10,7 +14,7 @@ export default class SnapshotTestRunner extends TestRunner {
10
14
  super.initTestCase(testCase);
11
15
 
12
16
  if (!testCase.goldenImage) {
13
- throw new Error(`Test case ${testCase.name} does not have golden image`);
17
+ throw new Error("Test case ".concat(testCase.name, " does not have golden image"));
14
18
  }
15
19
  }
16
20
 
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/snapshot-test-runner.ts"],"names":["TestRunner","getBoundingBoxInPage","SnapshotTestRunner","constructor","props","testOptions","imageDiffOptions","initTestCase","testCase","goldenImage","Error","name","shouldRender","isDiffing","assert","diffOptions","Object","assign","region","_animationProps","canvas","window","browserTestDriver_captureAndDiffScreen","then","result","success","_pass","_fail","_next"],"mappings":";AAAA,OAAOA,UAAP,MAA4C,eAA5C;AACA,SAAQC,oBAAR,QAAmC,SAAnC;AAGA,eAAe,MAAMC,kBAAN,SAAiCF,UAAjC,CAA4C;AAGzDG,EAAAA,WAAW,CAACC,KAAD,EAA2B;AACpC,UAAMA,KAAN;;AADoC,uCAFT,KAES;;AAIpC,SAAKC,WAAL,CAAiBC,gBAAjB,GAAoC,EAApC;AACD;;AAEDC,EAAAA,YAAY,CAACC,QAAD,EAAW;AACrB,UAAMD,YAAN,CAAmBC,QAAnB;;AACA,QAAI,CAACA,QAAQ,CAACC,WAAd,EAA2B;AACzB,YAAM,IAAIC,KAAJ,qBAAuBF,QAAQ,CAACG,IAAhC,iCAAN;AACD;AACF;;AAEDC,EAAAA,YAAY,GAAG;AAEb,WAAO,CAAC,KAAKC,SAAb;AACD;;AAEDC,EAAAA,MAAM,CAACN,QAAD,EAAW;AACf,QAAI,KAAKK,SAAT,EAAoB;AAElB;AACD;;AACD,SAAKA,SAAL,GAAiB,IAAjB;AAEA,UAAME,WAAW,GAAGC,MAAM,CAACC,MAAP,CAClB,EADkB,EAGlB,KAAKZ,WAAL,CAAiBC,gBAHC,EAIlBE,QAAQ,CAACF,gBAJS,EAKlB;AACEG,MAAAA,WAAW,EAAED,QAAQ,CAACC,WADxB;AAGES,MAAAA,MAAM,EAAEjB,oBAAoB,CAAC,KAAKkB,eAAL,CAAqBC,MAAtB;AAH9B,KALkB,CAApB;AAcAC,IAAAA,MAAM,CAACC,sCAAP,CAA8CP,WAA9C,EAA2DQ,IAA3D,CAAiEC,MAAD,IAAY;AAE1E,UAAIA,MAAM,CAACC,OAAX,EAAoB;AAClB,aAAKC,KAAL,CAAWF,MAAX;AACD,OAFD,MAEO;AACL,aAAKG,KAAL,CAAWH,MAAX;AACD;;AAED,WAAKX,SAAL,GAAiB,KAAjB;;AACA,WAAKe,KAAL;AACD,KAVD;AAWD;;AAtDwD","sourcesContent":["import TestRunner, {TestRunnerOptions} from './test-runner';\nimport {getBoundingBoxInPage} from './utils';\n\n\nexport default class SnapshotTestRunner extends TestRunner {\n private isDiffing: boolean = false;\n\n constructor(props: TestRunnerOptions) {\n super(props);\n\n // @ts-ignore\n this.testOptions.imageDiffOptions = {};\n }\n\n initTestCase(testCase) {\n super.initTestCase(testCase);\n if (!testCase.goldenImage) {\n throw new Error(`Test case ${testCase.name} does not have golden image`);\n }\n }\n\n shouldRender() {\n // wait for the current diffing to finish\n return !this.isDiffing;\n }\n\n assert(testCase) {\n if (this.isDiffing) {\n // Already performing diffing\n return;\n }\n this.isDiffing = true;\n\n const diffOptions = Object.assign(\n {},\n // @ts-ignore\n this.testOptions.imageDiffOptions,\n testCase.imageDiffOptions,\n {\n goldenImage: testCase.goldenImage,\n // @ts-ignore\n region: getBoundingBoxInPage(this._animationProps.canvas)\n }\n );\n\n // Take screenshot and compare\n // @ts-ignore\n window.browserTestDriver_captureAndDiffScreen(diffOptions).then((result) => {\n // invoke user callback\n if (result.success) {\n this._pass(result);\n } else {\n this._fail(result);\n }\n\n this.isDiffing = false;\n this._next();\n });\n }\n}\n"],"file":"snapshot-test-runner.js"}
@@ -0,0 +1,45 @@
1
+ export declare type TestRunnerTestCase = {
2
+ name: string;
3
+ onInitialize: any;
4
+ onRender: any;
5
+ onFinalize: any;
6
+ };
7
+ export declare type TestRunnerOptions = {
8
+ onTestStart?: any;
9
+ onTestPass?: any;
10
+ onTestFail?: any;
11
+ timeout?: number;
12
+ };
13
+ export default class TestRunner {
14
+ props: any;
15
+ isRunning: boolean;
16
+ readonly testOptions: object;
17
+ readonly _animationProps: object;
18
+ private _testCases;
19
+ private _testCaseData;
20
+ /**
21
+ * props
22
+ * AnimationLoop props
23
+ */
24
+ constructor(props?: {});
25
+ /**
26
+ * Add testCase(s)
27
+ */
28
+ /**
29
+ * Add testCase(s)
30
+ */
31
+ add(testCases: TestRunnerTestCase[]): this;
32
+ /**
33
+ * Returns a promise that resolves when all the test cases are done
34
+ */
35
+ run(options?: object): Promise<void>;
36
+ initTestCase(testCase: any): void;
37
+ shouldRender(animationProps: any): boolean;
38
+ assert(testCase: any): void;
39
+ _pass(result: any): void;
40
+ _fail(result: any): void;
41
+ _next(): void;
42
+ _onRender(animationProps: any): void;
43
+ _nextTestCase(): TestRunnerTestCase;
44
+ }
45
+ //# sourceMappingURL=test-runner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-runner.d.ts","sourceRoot":"","sources":["../src/test-runner.ts"],"names":[],"mappings":"AAKA,oBAAY,kBAAkB,GAAG;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,GAAG,CAAC;IAClB,QAAQ,EAAE,GAAG,CAAC;IACd,UAAU,EAAE,GAAG,CAAC;CACjB,CAAC;AAWF,oBAAY,iBAAiB,GAAG;IAE9B,WAAW,CAAC,EAAE,GAAG,CAAC;IAClB,UAAU,CAAC,EAAE,GAAG,CAAC;IACjB,UAAU,CAAC,EAAE,GAAG,CAAC;IAGjB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAYF,MAAM,CAAC,OAAO,OAAO,UAAU;IAC7B,KAAK,MAAC;IACN,SAAS,UAAS;IAClB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAM;IACtC,OAAO,CAAC,UAAU,CAA4B;IAC9C,OAAO,CAAC,aAAa,CAAQ;IAE7B;;;OAGG;gBACS,KAAK,KAAK;IAStB;;OAEG;IACH;;OAEG;IACF,GAAG,CAAC,SAAS,EAAE,kBAAkB,EAAE,GAAG,IAAI;IAU1C;;OAEG;IACJ,GAAG,CAAC,OAAO,GAAE,MAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IA0BxC,YAAY,CAAC,QAAQ,KAAA;IAYrB,YAAY,CAAC,cAAc,KAAA;IAI3B,MAAM,CAAC,QAAQ,KAAA;IAOf,KAAK,CAAC,MAAM,KAAA;IAKZ,KAAK,CAAC,MAAM,KAAA;IAKZ,KAAK;IAML,SAAS,CAAC,cAAc,KAAA;IAqCxB,aAAa;CAqDd"}
@@ -1,3 +1,4 @@
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
1
2
  import { AnimationLoop } from '@luma.gl/core';
2
3
  import { pushContextState, popContextState } from '@luma.gl/gltools';
3
4
 
@@ -12,18 +13,26 @@ const DEFAULT_TEST_CASE = {
12
13
  onFinalize: noop
13
14
  };
14
15
  const DEFAULT_TEST_OPTIONS = {
15
- onTestStart: testCase => console.log(`# ${testCase.name}`),
16
- onTestPass: testCase => console.log(`ok ${testCase.name} passed`),
17
- onTestFail: testCase => console.log(`not ok ${testCase.name} failed`),
16
+ onTestStart: testCase => console.log("# ".concat(testCase.name)),
17
+ onTestPass: testCase => console.log("ok ".concat(testCase.name, " passed")),
18
+ onTestFail: testCase => console.log("not ok ".concat(testCase.name, " failed")),
18
19
  timeout: 2000
19
20
  };
20
21
  export default class TestRunner {
21
22
  constructor(props = {}) {
23
+ _defineProperty(this, "props", void 0);
24
+
25
+ _defineProperty(this, "isRunning", false);
26
+
27
+ _defineProperty(this, "testOptions", void 0);
28
+
29
+ _defineProperty(this, "_animationProps", {});
30
+
31
+ _defineProperty(this, "_testCases", []);
32
+
33
+ _defineProperty(this, "_testCaseData", null);
34
+
22
35
  this.props = props;
23
- this.isRunning = false;
24
- this._animationProps = {};
25
- this._testCases = [];
26
- this._testCaseData = null;
27
36
  this.isHeadless = Boolean(window.browserTestDriver_isHeadless);
28
37
  this.testOptions = Object.assign({}, DEFAULT_TEST_OPTIONS);
29
38
  }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/test-runner.ts"],"names":["AnimationLoop","pushContextState","popContextState","noop","DEFAULT_TEST_CASE","name","onInitialize","onRender","done","onFinalize","DEFAULT_TEST_OPTIONS","onTestStart","testCase","console","log","onTestPass","onTestFail","timeout","TestRunner","constructor","props","isHeadless","Boolean","window","browserTestDriver_isHeadless","testOptions","Object","assign","add","testCases","Array","isArray","_testCases","push","run","options","Promise","resolve","_animationLoop","_onRender","bind","isRunning","start","isDiffing","_currentTestCase","catch","error","_fail","message","initTestCase","animationLoop","key","shouldRender","animationProps","assert","_pass","_next","result","_nextTestCase","_animationProps","stop","isDone","testCaseAnimationProps","_testCaseData","startTime","_currentTestCaseStartTime","time","tick","_currentTestCaseStartTick","value","delete","gl","shift","then","userData"],"mappings":";AAEA,SAAQA,aAAR,QAA4B,eAA5B;AACA,SAAQC,gBAAR,EAA0BC,eAA1B,QAAgD,kBAAhD;;AASA,SAASC,IAAT,GAAgB,CAAE;;AAElB,MAAMC,iBAAqC,GAAG;AAC5CC,EAAAA,IAAI,EAAE,cADsC;AAE5CC,EAAAA,YAAY,EAAEH,IAF8B;AAG5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IAnC,MAAAA,OAAO,CAACC,OAAR,CACEzB,QAAQ,CAACN,YAAT,CACEoB,MAAM,CAACC,MAAP,CAAc,EAAd,EAAkB0B,cAAlB,EAAkC;AAEhCW,QAAAA,SAAS,EAAEX,cAAc,CAACa,IAFM;AAGhCA,QAAAA,IAAI,EAAE,CAH0B;AAIhCC,QAAAA,IAAI,EAAE;AAJ0B,OAAlC,CADF,CADF,EASEM,IATF,CASQC,QAAD,IAAc;AACnB,aAAKX,aAAL,GAAqBW,QAAQ,IAAI,EAAjC;AACD,OAXD;AAaA,WAAKjD,WAAL,CAAiBd,WAAjB,CAA6BC,QAA7B;AACD;;AACD,WAAOA,QAAP;AACD;;AAlM6B","sourcesContent":["// @ts-nocheck TODO remove\n/* eslint-disable no-console */\nimport {AnimationLoop} from '@luma.gl/core';\nimport {pushContextState, popContextState} from '@luma.gl/gltools';\n\nexport type TestRunnerTestCase = {\n name: string;\n onInitialize: any;\n onRender: any;\n onFinalize: any;\n};\n\nfunction noop() {}\n\nconst DEFAULT_TEST_CASE: TestRunnerTestCase = {\n name: 'Unnamed test',\n onInitialize: noop,\n onRender: ({done}) => done(),\n onFinalize: noop\n};\n\nexport type TestRunnerOptions = {\n // test lifecycle callback\n onTestStart?: any;\n onTestPass?: any;\n onTestFail?: any;\n\n // milliseconds to wait for each test case before aborting\n timeout?: number;\n};\n\nconst DEFAULT_TEST_OPTIONS: Required<TestRunnerOptions> = {\n // test lifecycle callback\n onTestStart: (testCase) => console.log(`# ${testCase.name}`),\n onTestPass: (testCase) => console.log(`ok ${testCase.name} passed`),\n onTestFail: (testCase) => console.log(`not ok ${testCase.name} failed`),\n\n // milliseconds to wait for each test case before aborting\n timeout: 2000\n};\n\nexport default class TestRunner {\n props;\n isRunning = false;\n readonly testOptions: object;\n readonly _animationProps: object = {};\n private _testCases: TestRunnerTestCase[] = [];\n private _testCaseData = null;\n\n /**\n * props\n * AnimationLoop props\n */\n constructor(props = {}) {\n this.props = props;\n\n // @ts-ignore\n this.isHeadless = Boolean(window.browserTestDriver_isHeadless);\n\n this.testOptions = Object.assign({}, DEFAULT_TEST_OPTIONS);\n }\n\n /**\n * Add testCase(s)\n */\n /**\n * Add testCase(s)\n */\n add(testCases: TestRunnerTestCase[]): this {\n if (!Array.isArray(testCases)) {\n testCases = [testCases];\n }\n for (const testCase of testCases) {\n this._testCases.push(testCase);\n }\n return this;\n }\n\n /**\n * Returns a promise that resolves when all the test cases are done\n */\n run(options: object = {}): Promise<void> {\n Object.assign(this.testOptions, options);\n\n return new Promise<void>(resolve => {\n this._animationLoop = new AnimationLoop(\n // @ts-ignore TODO\n Object.assign({}, this.props, {\n onRender: this._onRender.bind(this),\n onFinalize: () => {\n this.isRunning = false;\n resolve();\n }\n })\n );\n this._animationLoop.start(this.props);\n\n this.isRunning = true;\n this.isDiffing = false;\n this._currentTestCase = null;\n }).catch((error) => {\n this._fail({error: error.message});\n });\n }\n\n /* Lifecycle methods for subclassing */\n\n initTestCase(testCase) {\n const {animationLoop} = testCase;\n if (animationLoop) {\n testCase.onInitialize = animationLoop.onInitialize.bind(animationLoop);\n testCase.onRender = animationLoop.onRender.bind(animationLoop);\n testCase.onFinalize = animationLoop.onFinalize.bind(animationLoop);\n }\n for (const key in DEFAULT_TEST_CASE) {\n testCase[key] = testCase[key] || DEFAULT_TEST_CASE[key];\n }\n }\n\n shouldRender(animationProps) {\n return true;\n }\n\n assert(testCase) {\n this._pass(testCase);\n this._next();\n }\n\n /* Utilities */\n\n _pass(result) {\n // @ts-ignore\n this.testOptions.onTestPass(this._currentTestCase, result);\n }\n\n _fail(result) {\n // @ts-ignore\n this.testOptions.onTestFail(this._currentTestCase, result);\n }\n\n _next() {\n this._nextTestCase();\n }\n\n /* Private methods */\n\n _onRender(animationProps) {\n this._animationProps = animationProps;\n\n const testCase = this._currentTestCase || this._nextTestCase();\n if (!testCase) {\n // all test cases are done\n this._animationLoop.stop();\n return;\n }\n\n let isDone = false;\n const testCaseAnimationProps = Object.assign({}, animationProps, this._testCaseData, {\n // tick/time starts from 0 for each test case\n startTime: this._currentTestCaseStartTime,\n time: animationProps.time - this._currentTestCaseStartTime,\n tick: animationProps.tick - this._currentTestCaseStartTick,\n // called by the test case when it is done rendering and ready for capture and diff\n done: () => {\n isDone = true;\n }\n });\n\n if (this._testCaseData && this.shouldRender(testCaseAnimationProps)) {\n // test case is initialized, render frame\n testCase.onRender(testCaseAnimationProps);\n }\n\n const timeout = testCase.timeout || this.testOptions.timeout;\n if (timeout && testCaseAnimationProps.time > timeout) {\n isDone = true;\n }\n\n if (isDone) {\n this.assert(testCase);\n }\n }\n\n _nextTestCase() {\n const animationProps = this._animationProps;\n\n // finalize the current test case\n if (this._testCaseData) {\n for (const key in this._testCaseData) {\n const value = this._testCaseData[key];\n if (value && value.delete) {\n value.delete();\n }\n }\n this._currentTestCase.onFinalize(Object.assign({}, animationProps, this._testCaseData));\n\n // reset WebGL context\n popContextState(animationProps.gl);\n\n this._currentTestCase = null;\n this._testCaseData = null;\n }\n\n // get the next test case\n const testCase = this._testCases.shift();\n if (testCase) {\n // start new test case\n this._currentTestCase = testCase;\n this._currentTestCaseStartTime = animationProps.time;\n this._currentTestCaseStartTick = animationProps.tick;\n this.initTestCase(testCase);\n\n // initialize test case\n\n // save WebGL context\n pushContextState(animationProps.gl);\n\n // aligned with the behavior of AnimationLoop.onInitialized\n // onInitialized could return a plain object or a promise\n Promise.resolve(\n testCase.onInitialize(\n Object.assign({}, animationProps, {\n // tick/time starts from 0 for each test case\n startTime: animationProps.time,\n time: 0,\n tick: 0\n })\n )\n ).then((userData) => {\n this._testCaseData = userData || {};\n });\n // invoke user callback\n this.testOptions.onTestStart(testCase);\n }\n return testCase;\n }\n}\n"],"file":"test-runner.js"}
@@ -0,0 +1,7 @@
1
+ export declare function getBoundingBoxInPage(domElement: any): {
2
+ x: any;
3
+ y: any;
4
+ width: any;
5
+ height: any;
6
+ };
7
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AACA,wBAAgB,oBAAoB,CAAC,UAAU,KAAA;;;;;EAQ9C"}
File without changes
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/utils.ts"],"names":["getBoundingBoxInPage","domElement","bbox","getBoundingClientRect","x","window","scrollX","y","scrollY","width","height"],"mappings":"AACA,OAAO,SAASA,oBAAT,CAA8BC,UAA9B,EAA0C;AAC/C,QAAMC,IAAI,GAAGD,UAAU,CAACE,qBAAX,EAAb;AACA,SAAO;AACLC,IAAAA,CAAC,EAAEC,MAAM,CAACC,OAAP,GAAiBJ,IAAI,CAACE,CADpB;AAELG,IAAAA,CAAC,EAAEF,MAAM,CAACG,OAAP,GAAiBN,IAAI,CAACK,CAFpB;AAGLE,IAAAA,KAAK,EAAEP,IAAI,CAACO,KAHP;AAILC,IAAAA,MAAM,EAAER,IAAI,CAACQ;AAJR,GAAP;AAMD","sourcesContent":["// Get the bounding box of a DOMElement relative to the page\nexport function getBoundingBoxInPage(domElement) {\n const bbox = domElement.getBoundingClientRect();\n return {\n x: window.scrollX + bbox.x,\n y: window.scrollY + bbox.y,\n width: bbox.width,\n height: bbox.height\n };\n}\n"],"file":"utils.js"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@luma.gl/test-utils",
3
- "version": "8.5.10",
3
+ "version": "8.6.0-alpha.1",
4
4
  "description": "Automated WebGL testing utilities with Puppeteer and image diffing",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -16,14 +16,17 @@
16
16
  "automation",
17
17
  "testing"
18
18
  ],
19
- "types": "src/index.d.ts",
20
- "main": "dist/es5/index.js",
21
- "module": "dist/esm/index.js",
19
+ "types": "src/index.ts",
20
+ "main": "dist/index.js",
21
+ "module": "dist/index.js",
22
22
  "files": [
23
23
  "src",
24
24
  "dist",
25
25
  "README.md"
26
26
  ],
27
+ "browser": {
28
+ "gl": false
29
+ },
27
30
  "scripts": {
28
31
  "pre-build": "echo test utils has no bundle"
29
32
  },
@@ -37,5 +40,5 @@
37
40
  "@luma.gl/webgl": "^8.4.0",
38
41
  "@probe.gl/test-utils": "^3.4.0"
39
42
  },
40
- "gitHead": "830155841c1e574d36061c2d71880a28d68b3cb3"
43
+ "gitHead": "e3895ce8a6dd376394c6662bb8cf0e1ad1f233f3"
41
44
  }
@@ -16,7 +16,7 @@ const CONTEXT_DEFAULTS = {
16
16
  throwOnError: false
17
17
  };
18
18
 
19
- export function createTestContext(opts = {}) {
19
+ export function createTestContext(opts = {}): WebGLRenderingContext {
20
20
  opts = Object.assign({}, CONTEXT_DEFAULTS, opts);
21
21
  const context = isBrowser()
22
22
  ? createGLContext(opts)
@@ -25,7 +25,8 @@ export function createTestContext(opts = {}) {
25
25
  }
26
26
 
27
27
  // Create headless gl context (for running under Node.js)
28
- export function createHeadlessContext(options) {
28
+ // Create headless gl context (for running under Node.js)
29
+ export function createHeadlessContext(options?: any): WebGLRenderingContext {
29
30
  const {width, height, webgl1, webgl2} = options;
30
31
 
31
32
  function onError(message) {
@@ -0,0 +1,36 @@
1
+ import headlessGL from 'gl';
2
+
3
+ const ERR_HEADLESSGL_FAILED =
4
+ 'Failed to create WebGL context in Node.js, headless gl returned null';
5
+
6
+ const ERR_HEADLESSGL_LOAD = `\
7
+ luma.gl: loaded under Node.js without headless gl installed, meaning that WebGL \
8
+ contexts can not be created. This may not be an error. For example, this is a \
9
+ typical configuration for isorender applications running on the server.`;
10
+
11
+ const CONTEXT_DEFAULTS = {
12
+ width: 1,
13
+ height: 1,
14
+ debug: true,
15
+ throwOnError: false
16
+ };
17
+
18
+ // Create headless gl context (for running under Node.js)
19
+ // Create headless gl context (for running under Node.js)
20
+ export function createHeadlessContext(options?: any): WebGLRenderingContext {
21
+ options = {...CONTEXT_DEFAULTS, ...options};
22
+
23
+ const {width, height, webgl1, webgl2} = options;
24
+
25
+ if (webgl2 && !webgl1) {
26
+ throw new Error('headless-gl does not support WebGL2');
27
+ }
28
+ if (!headlessGL) {
29
+ throw new Error(ERR_HEADLESSGL_LOAD);
30
+ }
31
+ const gl = headlessGL(width, height, options);
32
+ if (!gl) {
33
+ throw new Error(ERR_HEADLESSGL_FAILED);
34
+ }
35
+ return gl;
36
+ }
@@ -0,0 +1,20 @@
1
+ import {isBrowser} from 'probe.gl/env';
2
+ import {createGLContext, instrumentGLContext} from '@luma.gl/gltools';
3
+ import { createHeadlessContext } from './create-headless-context';
4
+
5
+ export function createTestContext(opts: Record<string, any> = {}): WebGLRenderingContext | null {
6
+ // try {
7
+ if (!isBrowser()) {
8
+ if (opts.webgl2 && !opts.webgl1) {
9
+ return null;
10
+ }
11
+ const gl = createHeadlessContext(opts);
12
+ return gl ? instrumentGLContext(gl) : null;
13
+ }
14
+ return createGLContext(opts);
15
+ // } catch {
16
+ // if (opts.webgl2) {
17
+ // return null;
18
+ // }
19
+ // }
20
+ }
@@ -1,3 +1,4 @@
1
1
  export {default as SnapshotTestRunner} from './snapshot-test-runner';
2
2
  export {default as PerformanceTestRunner} from './performance-test-runner';
3
- export {createTestContext, createHeadlessContext} from './context';
3
+ export {createHeadlessContext} from './create-headless-context';
4
+ export {createTestContext} from './create-test-context';
@@ -1,8 +1,11 @@
1
- import {Stats} from 'probe.gl';
2
- import TestRunner from './test-runner';
1
+ import {Stats, Stat} from 'probe.gl';
2
+ import TestRunner, {TestRunnerOptions} from './test-runner';
3
3
 
4
4
  export default class PerformanceTestRunner extends TestRunner {
5
- constructor(props) {
5
+ private _stats: Stats;
6
+ private _fps: Stat;
7
+
8
+ constructor(props: TestRunnerOptions) {
6
9
  super(props);
7
10
 
8
11
  Object.assign(this.testOptions, {
@@ -1,8 +1,11 @@
1
- import TestRunner from './test-runner';
1
+ import TestRunner, {TestRunnerOptions} from './test-runner';
2
2
  import {getBoundingBoxInPage} from './utils';
3
3
 
4
+
4
5
  export default class SnapshotTestRunner extends TestRunner {
5
- constructor(props) {
6
+ private isDiffing: boolean = false;
7
+
8
+ constructor(props: TestRunnerOptions) {
6
9
  super(props);
7
10
 
8
11
  // @ts-ignore
@@ -42,7 +45,7 @@ export default class SnapshotTestRunner extends TestRunner {
42
45
 
43
46
  // Take screenshot and compare
44
47
  // @ts-ignore
45
- window.browserTestDriver_captureAndDiffScreen(diffOptions).then(result => {
48
+ window.browserTestDriver_captureAndDiffScreen(diffOptions).then((result) => {
46
49
  // invoke user callback
47
50
  if (result.success) {
48
51
  this._pass(result);