@luma.gl/test-utils 8.5.4 → 8.5.8

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.
@@ -1,7 +1,10 @@
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 = " 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 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.`;
5
8
  const CONTEXT_DEFAULTS = {
6
9
  width: 1,
7
10
  height: 1,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/context.js"],"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;AAIvBC,EAAAA,YAAY,EAAE;AAJS,CAAzB;AAOA,OAAO,SAASC,iBAAT,CAA2BC,IAAI,GAAG,EAAlC,EAAsC;AAC3CA,EAAAA,IAAI,GAAGC,MAAM,CAACC,MAAP,CAAc,EAAd,EAAkBR,gBAAlB,EAAoCM,IAApC,CAAP;AACA,QAAMG,OAAO,GAAGZ,SAAS,KACrBF,eAAe,CAACW,IAAD,CADM,GAErBV,mBAAmB,CAACc,qBAAqB,CAACJ,IAAD,CAAtB,EAA8BA,IAA9B,CAFvB;AAGA,SAAOG,OAAP;AACD;AAGD,OAAO,SAASC,qBAAT,CAA+BC,OAA/B,EAAwC;AAC7C,QAAM;AAACV,IAAAA,KAAD;AAAQC,IAAAA,MAAR;AAAgBU,IAAAA,MAAhB;AAAwBC,IAAAA;AAAxB,MAAkCF,OAAxC;;AAEA,WAASG,OAAT,CAAiBC,OAAjB,EAA0B;AACxB,QAAIJ,OAAO,CAACP,YAAZ,EAA0B;AACxB,YAAM,IAAIY,KAAJ,CAAUD,OAAV,CAAN;AACD;;AACD,WAAO,IAAP;AACD;;AAED,MAAIF,MAAM,IAAI,CAACD,MAAf,EAAuB;AACrB,WAAOE,OAAO,CAAC,qCAAD,CAAd;AACD;;AACD,QAAMG,EAAE,GAAGC,UAAU,CAACjB,KAAD,EAAQC,MAAR,EAAgBS,OAAhB,CAArB;;AACA,MAAI,CAACM,EAAL,EAAS;AACP,WAAOH,OAAO,CAAChB,qBAAD,CAAd;AACD;;AACD,SAAOmB,EAAP;AACD;;AAGD,SAASC,UAAT,CAAoB,GAAGC,IAAvB,EAA6B;AAC3B,QAAMC,QAAQ,GAAGC,MAAM,CAACC,OAAP,CAAe,IAAf,CAAjB;;AACA,MAAI,CAACF,QAAL,EAAe;AACb,UAAM,IAAIJ,KAAJ,CAAUjB,mBAAV,CAAN;AACD;;AACD,SAAOqB,QAAQ,CAAC,GAAGD,IAAJ,CAAf;AACD","sourcesContent":["import {createGLContext, instrumentGLContext} from '@luma.gl/gltools';\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 = {}) {\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)\nexport function createHeadlessContext(options) {\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"}
1
+ {"version":3,"sources":["../../src/context.js"],"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,GAAI;AAC7B;AACA;AACA,0EAHA;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;AAOA,OAAO,SAASC,iBAAT,CAA2BC,IAAI,GAAG,EAAlC,EAAsC;AAC3CA,EAAAA,IAAI,GAAGC,MAAM,CAACC,MAAP,CAAc,EAAd,EAAkBR,gBAAlB,EAAoCM,IAApC,CAAP;AACA,QAAMG,OAAO,GAAGZ,SAAS,KACrBF,eAAe,CAACW,IAAD,CADM,GAErBV,mBAAmB,CAACc,qBAAqB,CAACJ,IAAD,CAAtB,EAA8BA,IAA9B,CAFvB;AAGA,SAAOG,OAAP;AACD;AAGD,OAAO,SAASC,qBAAT,CAA+BC,OAA/B,EAAwC;AAC7C,QAAM;AAACV,IAAAA,KAAD;AAAQC,IAAAA,MAAR;AAAgBU,IAAAA,MAAhB;AAAwBC,IAAAA;AAAxB,MAAkCF,OAAxC;;AAEA,WAASG,OAAT,CAAiBC,OAAjB,EAA0B;AACxB,QAAIJ,OAAO,CAACP,YAAZ,EAA0B;AACxB,YAAM,IAAIY,KAAJ,CAAUD,OAAV,CAAN;AACD;;AACD,WAAO,IAAP;AACD;;AAED,MAAIF,MAAM,IAAI,CAACD,MAAf,EAAuB;AACrB,WAAOE,OAAO,CAAC,qCAAD,CAAd;AACD;;AACD,QAAMG,EAAE,GAAGC,UAAU,CAACjB,KAAD,EAAQC,MAAR,EAAgBS,OAAhB,CAArB;;AACA,MAAI,CAACM,EAAL,EAAS;AACP,WAAOH,OAAO,CAAChB,qBAAD,CAAd;AACD;;AACD,SAAOmB,EAAP;AACD;;AAGD,SAASC,UAAT,CAAoB,GAAGC,IAAvB,EAA6B;AAC3B,QAAMC,QAAQ,GAAGC,MAAM,CAACC,OAAP,CAAe,IAAf,CAAjB;;AACA,MAAI,CAACF,QAAL,EAAe;AACb,UAAM,IAAIJ,KAAJ,CAAUjB,mBAAV,CAAN;AACD;;AACD,SAAOqB,QAAQ,CAAC,GAAGD,IAAJ,CAAf;AACD","sourcesContent":["import {createGLContext, instrumentGLContext} from '@luma.gl/gltools';\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 = {}) {\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)\nexport function createHeadlessContext(options) {\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"}
@@ -10,7 +10,7 @@ export default class SnapshotTestRunner extends TestRunner {
10
10
  super.initTestCase(testCase);
11
11
 
12
12
  if (!testCase.goldenImage) {
13
- throw new Error("Test case ".concat(testCase.name, " does not have golden image"));
13
+ throw new Error(`Test case ${testCase.name} does not have golden image`);
14
14
  }
15
15
  }
16
16
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/snapshot-test-runner.js"],"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,MAAuB,eAAvB;AACA,SAAQC,oBAAR,QAAmC,SAAnC;AAEA,eAAe,MAAMC,kBAAN,SAAiCF,UAAjC,CAA4C;AACzDG,EAAAA,WAAW,CAACC,KAAD,EAAQ;AACjB,UAAMA,KAAN;AAGA,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,CAAgEC,MAAM,IAAI;AAExE,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;;AApDwD","sourcesContent":["import TestRunner from './test-runner';\nimport {getBoundingBoxInPage} from './utils';\n\nexport default class SnapshotTestRunner extends TestRunner {\n constructor(props) {\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"}
1
+ {"version":3,"sources":["../../src/snapshot-test-runner.js"],"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,MAAuB,eAAvB;AACA,SAAQC,oBAAR,QAAmC,SAAnC;AAEA,eAAe,MAAMC,kBAAN,SAAiCF,UAAjC,CAA4C;AACzDG,EAAAA,WAAW,CAACC,KAAD,EAAQ;AACjB,UAAMA,KAAN;AAGA,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,CAAW,aAAYF,QAAQ,CAACG,IAAK,6BAArC,CAAN;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,CAAgEC,MAAM,IAAI;AAExE,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;;AApDwD","sourcesContent":["import TestRunner from './test-runner';\nimport {getBoundingBoxInPage} from './utils';\n\nexport default class SnapshotTestRunner extends TestRunner {\n constructor(props) {\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"}
@@ -12,9 +12,9 @@ const DEFAULT_TEST_CASE = {
12
12
  onFinalize: noop
13
13
  };
14
14
  const DEFAULT_TEST_OPTIONS = {
15
- onTestStart: testCase => console.log("# ".concat(testCase.name)),
16
- onTestPass: testCase => console.log("ok ".concat(testCase.name, " passed")),
17
- onTestFail: testCase => console.log("not ok ".concat(testCase.name, " failed")),
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`),
18
18
  timeout: 2000
19
19
  };
20
20
  export default class TestRunner {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/test-runner.js"],"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","isRunning","_animationProps","_testCases","_testCaseData","isHeadless","Boolean","window","browserTestDriver_isHeadless","testOptions","Object","assign","add","testCases","Array","isArray","push","run","options","Promise","resolve","_animationLoop","_onRender","bind","start","isDiffing","_currentTestCase","catch","error","_fail","message","initTestCase","animationLoop","key","shouldRender","animationProps","assert","_pass","_next","result","_nextTestCase","stop","isDone","testCaseAnimationProps","startTime","_currentTestCaseStartTime","time","tick","_currentTestCaseStartTick","value","delete","gl","shift","then","userData"],"mappings":"AACA,SAAQA,aAAR,QAA4B,eAA5B;AACA,SAAQC,gBAAR,EAA0BC,eAA1B,QAAgD,kBAAhD;;AAEA,SAASC,IAAT,GAAgB,CAAE;;AAElB,MAAMC,iBAAiB,GAAG;AACxBC,EAAAA,IAAI,EA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,YAAL,CAAkBvC,QAAlB;AAKAX,MAAAA,gBAAgB,CAACsD,cAAc,CAACgB,EAAhB,CAAhB;AAIAhC,MAAAA,OAAO,CAACC,OAAR,CACE5B,QAAQ,CAACN,YAAT,CACEwB,MAAM,CAACC,MAAP,CAAc,EAAd,EAAkBwB,cAAlB,EAAkC;AAEhCS,QAAAA,SAAS,EAAET,cAAc,CAACW,IAFM;AAGhCA,QAAAA,IAAI,EAAE,CAH0B;AAIhCC,QAAAA,IAAI,EAAE;AAJ0B,OAAlC,CADF,CADF,EASEM,IATF,CASOC,QAAQ,IAAI;AACjB,aAAKlD,aAAL,GAAqBkD,QAAQ,IAAI,EAAjC;AACD,OAXD;AAaA,WAAK7C,WAAL,CAAiBlB,WAAjB,CAA6BC,QAA7B;AACD;;AACD,WAAOA,QAAP;AACD;;AA5L6B","sourcesContent":["/* eslint-disable no-console */\nimport {AnimationLoop} from '@luma.gl/core';\nimport {pushContextState, popContextState} from '@luma.gl/gltools';\n\nfunction noop() {}\n\nconst DEFAULT_TEST_CASE = {\n name: 'Unnamed test',\n onInitialize: noop,\n onRender: ({done}) => done(),\n onFinalize: noop\n};\n\nconst DEFAULT_TEST_OPTIONS = {\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 /**\n * props\n * AnimationLoop props\n */\n constructor(props = {}) {\n this.props = props;\n this.isRunning = false;\n this._animationProps = {};\n this._testCases = [];\n this._testCaseData = null;\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 add(testCases) {\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 = {}) {\n Object.assign(this.testOptions, options);\n\n return new Promise(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"}
1
+ {"version":3,"sources":["../../src/test-runner.js"],"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","isRunning","_animationProps","_testCases","_testCaseData","isHeadless","Boolean","window","browserTestDriver_isHeadless","testOptions","Object","assign","add","testCases","Array","isArray","push","run","options","Promise","resolve","_animationLoop","_onRender","bind","start","isDiffing","_currentTestCase","catch","error","_fail","message","initTestCase","animationLoop","key","shouldRender","animationProps","assert","_pass","_next","result","_nextTestCase","stop","isDone","testCaseAnimationProps","startTime","_currentTestCaseStartTime","time","tick","_currentTestCaseStartTick","value","delete","gl","shift","then","userData"],"mappings":"AACA,SAAQA,aAAR,QAA4B,eAA5B;AACA,SAAQC,gBAAR,EAA0BC,eAA1B,QAAgD,kBAAhD;;AAEA,SAASC,IAAT,GAAgB,CAAE;;AAElB,MAAMC,iBAAiB,GAAG;AACxBC,EAAAA,IAAI,EAAE,cADkB;AAExBC,EAAAA,YAAY,EAAEH,IAFU;AAGxBI,EAAAA,QAAQ,EAAE,CAAC;AAACC,IAAAA;AAAD,GAAD,KAAYA,IAAI,EAHF;AAIxBC,EAAAA,UAAU,EAAEN;AAJY,CAA1B;AAOA,MAAMO,oBAAoB,GAAG;AAE3BC,EAAAA,WAAW,EAAEC,QAAQ,IAAIC,OAAO,CAACC,GAAR,CAAa,KAAIF,QAAQ,CAACP,IAAK,EAA/B,CAFE;AAG3BU,EAAAA,UAAU,EAAEH,QAAQ,IAAIC,OAAO,CAACC,GAAR,CAAa,MAAKF,QAAQ,CAACP,IAAK,SAAhC,CAHG;AAI3BW,EAAAA,UAAU,EAAEJ,QAAQ,IAAIC,OAAO,CAACC,GAAR,CAAa,UAASF,QAAQ,CAACP,IAAK,SAApC,CAJG;AAO3BY,EAAAA,OAAO,EAAE;AAPkB,CAA7B;AAUA,eAAe,MAAMC,UAAN,CAAiB;AAK9BC,EAAAA,WAAW,CAACC,KAAK,GAAG,EAAT,EAAa;AACtB,SAAKA,KAAL,GAAaA,KAAb;AACA,SAAKC,SAAL,GAAiB,KAAjB;AACA,SAAKC,eAAL,GAAuB,EAAvB;AACA,SAAKC,UAAL,GAAkB,EAAlB;AACA,SAAKC,aAAL,GAAqB,IAArB;AAGA,SAAKC,UAAL,GAAkBC,OAAO,CAACC,MAAM,CAACC,4BAAR,CAAzB;AAEA,SAAKC,WAAL,GAAmBC,MAAM,CAACC,MAAP,CAAc,EAAd,EAAkBrB,oBAAlB,CAAnB;AACD;;AAKDsB,EAAAA,GAAG,CAACC,SAAD,EAA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tB,aAAL,GAAqB,IAArB;AACD;;AAGD,UAAMZ,QAAQ,GAAG,KAAKW,UAAL,CAAgBiD,KAAhB,EAAjB;;AACA,QAAI5D,QAAJ,EAAc;AAEZ,WAAKkC,gBAAL,GAAwBlC,QAAxB;AACA,WAAKqD,yBAAL,GAAiCV,cAAc,CAACW,IAAhD;AACA,WAAKE,yBAAL,GAAiCb,cAAc,CAACY,IAAhD;AACA,WAAKhB,YAAL,CAAkBvC,QAAlB;AAKAX,MAAAA,gBAAgB,CAACsD,cAAc,CAACgB,EAAhB,CAAhB;AAIAhC,MAAAA,OAAO,CAACC,OAAR,CACE5B,QAAQ,CAACN,YAAT,CACEwB,MAAM,CAACC,MAAP,CAAc,EAAd,EAAkBwB,cAAlB,EAAkC;AAEhCS,QAAAA,SAAS,EAAET,cAAc,CAACW,IAFM;AAGhCA,QAAAA,IAAI,EAAE,CAH0B;AAIhCC,QAAAA,IAAI,EAAE;AAJ0B,OAAlC,CADF,CADF,EASEM,IATF,CASOC,QAAQ,IAAI;AACjB,aAAKlD,aAAL,GAAqBkD,QAAQ,IAAI,EAAjC;AACD,OAXD;AAaA,WAAK7C,WAAL,CAAiBlB,WAAjB,CAA6BC,QAA7B;AACD;;AACD,WAAOA,QAAP;AACD;;AA5L6B","sourcesContent":["/* eslint-disable no-console */\nimport {AnimationLoop} from '@luma.gl/core';\nimport {pushContextState, popContextState} from '@luma.gl/gltools';\n\nfunction noop() {}\n\nconst DEFAULT_TEST_CASE = {\n name: 'Unnamed test',\n onInitialize: noop,\n onRender: ({done}) => done(),\n onFinalize: noop\n};\n\nconst DEFAULT_TEST_OPTIONS = {\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 /**\n * props\n * AnimationLoop props\n */\n constructor(props = {}) {\n this.props = props;\n this.isRunning = false;\n this._animationProps = {};\n this._testCases = [];\n this._testCaseData = null;\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 add(testCases) {\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 = {}) {\n Object.assign(this.testOptions, options);\n\n return new Promise(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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@luma.gl/test-utils",
3
- "version": "8.5.4",
3
+ "version": "8.5.8",
4
4
  "description": "Automated WebGL testing utilities with Puppeteer and image diffing",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -37,5 +37,5 @@
37
37
  "@luma.gl/webgl": "^8.4.0",
38
38
  "@probe.gl/test-utils": "^3.4.0"
39
39
  },
40
- "gitHead": "b393af402e7002969af7358bc3432506cd2583cb"
40
+ "gitHead": "ec6897d6a3df73e30a4f31be904b2fba4fcac191"
41
41
  }