@luma.gl/test-utils 9.0.0-alpha.20 → 9.0.0-alpha.21
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.
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/performance-test-runner.d.ts +2 -2
- package/dist/performance-test-runner.d.ts.map +1 -1
- package/dist/performance-test-runner.js +2 -2
- package/dist/performance-test-runner.js.map +1 -1
- package/dist/snapshot-test-runner.d.ts +2 -2
- package/dist/snapshot-test-runner.d.ts.map +1 -1
- package/dist/snapshot-test-runner.js +2 -2
- package/dist/snapshot-test-runner.js.map +1 -1
- package/dist/test-runner.d.ts +1 -1
- package/dist/test-runner.d.ts.map +1 -1
- package/dist/test-runner.js +1 -1
- package/dist/test-runner.js.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +2 -2
- package/src/performance-test-runner.ts +2 -2
- package/src/snapshot-test-runner.ts +2 -2
- package/src/test-runner.ts +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import './register-devices';
|
|
2
2
|
export type { TestRunnerTestCase } from './test-runner';
|
|
3
3
|
export type { SnapshotTestRunnerTestCase } from './snapshot-test-runner';
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
4
|
+
export { SnapshotTestRunner } from './snapshot-test-runner';
|
|
5
|
+
export { PerformanceTestRunner } from './performance-test-runner';
|
|
6
6
|
export { createTestDevice, createTestContext, webgl1Device, webgl2Device, webgpuDevice } from './create-test-device';
|
|
7
7
|
export { getTestDevices, getWebGLTestDevices } from './create-test-device';
|
|
8
8
|
export { checkType } from './check-type';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,CAAC;AAE5B,YAAY,EAAC,kBAAkB,EAAC,MAAM,eAAe,CAAC;AACtD,YAAY,EAAC,0BAA0B,EAAC,MAAM,wBAAwB,CAAC;AAEvE,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,CAAC;AAE5B,YAAY,EAAC,kBAAkB,EAAC,MAAM,eAAe,CAAC;AACtD,YAAY,EAAC,0BAA0B,EAAC,MAAM,wBAAwB,CAAC;AAEvE,OAAO,EAAC,kBAAkB,EAAC,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAC,qBAAqB,EAAC,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAC,gBAAgB,EAAE,iBAAiB,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAC,MAAM,sBAAsB,CAAC;AACnH,OAAO,EAAC,cAAc,EAAE,mBAAmB,EAAC,MAAM,sBAAsB,CAAC;AAEzE,OAAO,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "./register-devices.js";
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
2
|
+
export { SnapshotTestRunner } from "./snapshot-test-runner.js";
|
|
3
|
+
export { PerformanceTestRunner } from "./performance-test-runner.js";
|
|
4
4
|
export { createTestDevice, createTestContext, webgl1Device, webgl2Device, webgpuDevice } from "./create-test-device.js";
|
|
5
5
|
export { getTestDevices, getWebGLTestDevices } from "./create-test-device.js";
|
|
6
6
|
export { checkType } from "./check-type.js";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["
|
|
1
|
+
{"version":3,"file":"index.js","names":["SnapshotTestRunner","PerformanceTestRunner","createTestDevice","createTestContext","webgl1Device","webgl2Device","webgpuDevice","getTestDevices","getWebGLTestDevices","checkType"],"sources":["../src/index.ts"],"sourcesContent":["import './register-devices';\n\nexport type {TestRunnerTestCase} from './test-runner';\nexport type {SnapshotTestRunnerTestCase} from './snapshot-test-runner';\n\nexport {SnapshotTestRunner} from './snapshot-test-runner';\nexport {PerformanceTestRunner} from './performance-test-runner';\nexport {createTestDevice, createTestContext, webgl1Device, webgl2Device, webgpuDevice} from './create-test-device';\nexport {getTestDevices, getWebGLTestDevices} from './create-test-device';\n\nexport {checkType} from './check-type';\n"],"mappings":";SAKQA,kBAAkB;AAAA,SAClBC,qBAAqB;AAAA,SACrBC,gBAAgB,EAAEC,iBAAiB,EAAEC,YAAY,EAAEC,YAAY,EAAEC,YAAY;AAAA,SAC7EC,cAAc,EAAEC,mBAAmB;AAAA,SAEnCC,SAAS"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import TestRunner,
|
|
1
|
+
import { TestRunner, TestRunnerProps, TestRunnerTestCase } from './test-runner';
|
|
2
2
|
export declare type PerformanceTestRunnerProps = TestRunnerProps;
|
|
3
|
-
export
|
|
3
|
+
export declare class PerformanceTestRunner extends TestRunner {
|
|
4
4
|
private _stats;
|
|
5
5
|
private _fps;
|
|
6
6
|
constructor(props: PerformanceTestRunnerProps);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"performance-test-runner.d.ts","sourceRoot":"","sources":["../src/performance-test-runner.ts"],"names":[],"mappings":"AAGA,OAAO,UAAU,EAAE,
|
|
1
|
+
{"version":3,"file":"performance-test-runner.d.ts","sourceRoot":"","sources":["../src/performance-test-runner.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,UAAU,EAAE,eAAe,EAAE,kBAAkB,EAAC,MAAM,eAAe,CAAC;AAE9E,oBAAY,0BAA0B,GAAG,eAAe,CAAC;AAEzD,qBAAa,qBAAsB,SAAQ,UAAU;IACnD,OAAO,CAAC,MAAM,CAAsB;IACpC,OAAO,CAAC,IAAI,CAAqB;gBAErB,KAAK,EAAE,0BAA0B;IASpC,YAAY,CAAC,QAAQ,EAAE,kBAAkB,GAAG,IAAI;IAMhD,YAAY,CAAC,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO;IAW1D,MAAM,CAAC,QAAQ,EAAE,kBAAkB,GAAG,IAAI;CAapD"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
2
|
import { Stats } from '@probe.gl/stats';
|
|
3
|
-
import TestRunner from "./test-runner.js";
|
|
4
|
-
export
|
|
3
|
+
import { TestRunner } from "./test-runner.js";
|
|
4
|
+
export class PerformanceTestRunner extends TestRunner {
|
|
5
5
|
constructor(props) {
|
|
6
6
|
super(props);
|
|
7
7
|
_defineProperty(this, "_stats", null);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"performance-test-runner.js","names":["Stats","TestRunner","PerformanceTestRunner","constructor","props","_defineProperty","Object","assign","testOptions","maxFramesToRender","targetFPS","initTestCase","testCase","_stats","id","name","_fps","get","shouldRender","animationProps","_this$_fps","_this$_fps2","timeEnd","timeStart","count","done","assert","_this$_fps3","_this$_fps4","fps","getHz","_pass","framesRendered","_fail","_next"],"sources":["../src/performance-test-runner.ts"],"sourcesContent":["// luma.gl, MIT license\n\nimport {Stats, Stat} from '@probe.gl/stats';\nimport TestRunner,
|
|
1
|
+
{"version":3,"file":"performance-test-runner.js","names":["Stats","TestRunner","PerformanceTestRunner","constructor","props","_defineProperty","Object","assign","testOptions","maxFramesToRender","targetFPS","initTestCase","testCase","_stats","id","name","_fps","get","shouldRender","animationProps","_this$_fps","_this$_fps2","timeEnd","timeStart","count","done","assert","_this$_fps3","_this$_fps4","fps","getHz","_pass","framesRendered","_fail","_next"],"sources":["../src/performance-test-runner.ts"],"sourcesContent":["// luma.gl, MIT license\n\nimport {Stats, Stat} from '@probe.gl/stats';\nimport {TestRunner, TestRunnerProps, TestRunnerTestCase} from './test-runner';\n\nexport type PerformanceTestRunnerProps = TestRunnerProps;\n\nexport class PerformanceTestRunner extends TestRunner {\n private _stats: Stats | null = null;\n private _fps: Stat | null = null;\n\n constructor(props: PerformanceTestRunnerProps) {\n super(props);\n\n Object.assign(this.testOptions, {\n maxFramesToRender: 60,\n targetFPS: 50\n });\n }\n\n override initTestCase(testCase: TestRunnerTestCase): void {\n super.initTestCase(testCase);\n this._stats = new Stats({id: testCase.name});\n this._fps = this._stats.get('fps');\n }\n\n override shouldRender(animationProps: Record<string, any>): boolean {\n this._fps?.timeEnd();\n this._fps?.timeStart();\n\n if (this._fps.count > this.testOptions.maxFramesToRender) {\n animationProps.done();\n }\n\n return true;\n }\n\n override assert(testCase: TestRunnerTestCase): void {\n // @ts-expect-error\n const targetFPS = testCase.targetFPS || this.testOptions.targetFPS;\n const count = this._fps?.count;\n const fps = this._fps?.getHz() || 0;\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"],"mappings":";AAEA,SAAQA,KAAK,QAAa,iBAAiB;AAAC,SACpCC,UAAU;AAIlB,OAAO,MAAMC,qBAAqB,SAASD,UAAU,CAAC;EAIpDE,WAAWA,CAACC,KAAiC,EAAE;IAC7C,KAAK,CAACA,KAAK,CAAC;IAACC,eAAA,iBAJgB,IAAI;IAAAA,eAAA,eACP,IAAI;IAK9BC,MAAM,CAACC,MAAM,CAAC,IAAI,CAACC,WAAW,EAAE;MAC9BC,iBAAiB,EAAE,EAAE;MACrBC,SAAS,EAAE;IACb,CAAC,CAAC;EACJ;EAESC,YAAYA,CAACC,QAA4B,EAAQ;IACxD,KAAK,CAACD,YAAY,CAACC,QAAQ,CAAC;IAC5B,IAAI,CAACC,MAAM,GAAG,IAAIb,KAAK,CAAC;MAACc,EAAE,EAAEF,QAAQ,CAACG;IAAI,CAAC,CAAC;IAC5C,IAAI,CAACC,IAAI,GAAG,IAAI,CAACH,MAAM,CAACI,GAAG,CAAC,KAAK,CAAC;EACpC;EAESC,YAAYA,CAACC,cAAmC,EAAW;IAAA,IAAAC,UAAA,EAAAC,WAAA;IAClE,CAAAD,UAAA,OAAI,CAACJ,IAAI,cAAAI,UAAA,uBAATA,UAAA,CAAWE,OAAO,EAAE;IACpB,CAAAD,WAAA,OAAI,CAACL,IAAI,cAAAK,WAAA,uBAATA,WAAA,CAAWE,SAAS,EAAE;IAEtB,IAAI,IAAI,CAACP,IAAI,CAACQ,KAAK,GAAG,IAAI,CAAChB,WAAW,CAACC,iBAAiB,EAAE;MACxDU,cAAc,CAACM,IAAI,EAAE;IACvB;IAEA,OAAO,IAAI;EACb;EAESC,MAAMA,CAACd,QAA4B,EAAQ;IAAA,IAAAe,WAAA,EAAAC,WAAA;IAElD,MAAMlB,SAAS,GAAGE,QAAQ,CAACF,SAAS,IAAI,IAAI,CAACF,WAAW,CAACE,SAAS;IAClE,MAAMc,KAAK,IAAAG,WAAA,GAAG,IAAI,CAACX,IAAI,cAAAW,WAAA,uBAATA,WAAA,CAAWH,KAAK;IAC9B,MAAMK,GAAG,GAAG,EAAAD,WAAA,OAAI,CAACZ,IAAI,cAAAY,WAAA,uBAATA,WAAA,CAAWE,KAAK,EAAE,KAAI,CAAC;IAEnC,IAAID,GAAG,IAAInB,SAAS,EAAE;MACpB,IAAI,CAACqB,KAAK,CAAC;QAACF,GAAG;QAAEG,cAAc,EAAER;MAAK,CAAC,CAAC;IAC1C,CAAC,MAAM;MACL,IAAI,CAACS,KAAK,CAAC;QAACJ,GAAG;QAAEG,cAAc,EAAER;MAAK,CAAC,CAAC;IAC1C;IACA,IAAI,CAACU,KAAK,EAAE;EACd;AACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import TestRunner,
|
|
1
|
+
import { TestRunner, TestRunnerProps, TestRunnerTestCase } from './test-runner';
|
|
2
2
|
/** A snapshot test case */
|
|
3
3
|
export declare type SnapshotTestRunnerTestCase = TestRunnerTestCase & {
|
|
4
4
|
/** URL to golden image */
|
|
@@ -9,7 +9,7 @@ export declare type SnapshotTestRunnerTestCase = TestRunnerTestCase & {
|
|
|
9
9
|
};
|
|
10
10
|
};
|
|
11
11
|
export declare type SnapshotTestRunnerProps = TestRunnerProps;
|
|
12
|
-
export
|
|
12
|
+
export declare class SnapshotTestRunner extends TestRunner {
|
|
13
13
|
private isDiffing;
|
|
14
14
|
constructor(props: SnapshotTestRunnerProps);
|
|
15
15
|
initTestCase(testCase: SnapshotTestRunnerTestCase): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"snapshot-test-runner.d.ts","sourceRoot":"","sources":["../src/snapshot-test-runner.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,EAAE,
|
|
1
|
+
{"version":3,"file":"snapshot-test-runner.d.ts","sourceRoot":"","sources":["../src/snapshot-test-runner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,eAAe,EAAE,kBAAkB,EAAC,MAAM,eAAe,CAAC;AAG9E,2BAA2B;AAC3B,oBAAY,0BAA0B,GAAG,kBAAkB,GAAG;IAC5D,0BAA0B;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,mBAAmB;IACnB,gBAAgB,CAAC,EAAE;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAC,CAAC;CACzC,CAAA;AAED,oBAAY,uBAAuB,GAAG,eAAe,CAAC;AAEtD,qBAAa,kBAAmB,SAAQ,UAAU;IAChD,OAAO,CAAC,SAAS,CAAkB;gBAEvB,KAAK,EAAE,uBAAuB;IAKjC,YAAY,CAAC,QAAQ,EAAE,0BAA0B,GAAG,IAAI;IAOxD,YAAY,IAAI,OAAO;IAKjB,MAAM,CAAC,QAAQ,EAAE,0BAA0B,GAAG,OAAO,CAAC,IAAI,CAAC;CAgC3E"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
-
import TestRunner from "./test-runner.js";
|
|
2
|
+
import { TestRunner } from "./test-runner.js";
|
|
3
3
|
import { getBoundingBoxInPage } from "./utils.js";
|
|
4
|
-
export
|
|
4
|
+
export class SnapshotTestRunner extends TestRunner {
|
|
5
5
|
constructor(props) {
|
|
6
6
|
super(props);
|
|
7
7
|
_defineProperty(this, "isDiffing", false);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"snapshot-test-runner.js","names":["TestRunner","getBoundingBoxInPage","SnapshotTestRunner","constructor","props","_defineProperty","testOptions","imageDiffOptions","initTestCase","testCase","goldenImage","Error","concat","name","shouldRender","isDiffing","assert","_this$_animationProps","canvas","_animationProps","HTMLCanvasElement","diffOptions","region","result","globalThis","browserTestDriver_captureAndDiffScreen","success","_pass","_fail","_next"],"sources":["../src/snapshot-test-runner.ts"],"sourcesContent":["import TestRunner,
|
|
1
|
+
{"version":3,"file":"snapshot-test-runner.js","names":["TestRunner","getBoundingBoxInPage","SnapshotTestRunner","constructor","props","_defineProperty","testOptions","imageDiffOptions","initTestCase","testCase","goldenImage","Error","concat","name","shouldRender","isDiffing","assert","_this$_animationProps","canvas","_animationProps","HTMLCanvasElement","diffOptions","region","result","globalThis","browserTestDriver_captureAndDiffScreen","success","_pass","_fail","_next"],"sources":["../src/snapshot-test-runner.ts"],"sourcesContent":["import {TestRunner, TestRunnerProps, TestRunnerTestCase} from './test-runner';\nimport {getBoundingBoxInPage} from './utils';\n\n/** A snapshot test case */\nexport type SnapshotTestRunnerTestCase = TestRunnerTestCase & {\n /** URL to golden image */\n goldenImage: string;\n /** Diff options */\n imageDiffOptions?: {[key: string]: any}; \n}\n\nexport type SnapshotTestRunnerProps = TestRunnerProps;\n\nexport class SnapshotTestRunner extends TestRunner {\n private isDiffing: boolean = false;\n\n constructor(props: SnapshotTestRunnerProps) {\n super(props);\n this.testOptions.imageDiffOptions = {};\n }\n\n override initTestCase(testCase: SnapshotTestRunnerTestCase): void {\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 override shouldRender(): boolean {\n // wait for the current diffing to finish\n return !this.isDiffing;\n }\n\n override async assert(testCase: SnapshotTestRunnerTestCase): Promise<void> {\n if (this.isDiffing) {\n // Already performing diffing\n return;\n }\n this.isDiffing = true;\n\n const canvas = this._animationProps?.canvas;\n if (!(canvas instanceof HTMLCanvasElement)) {\n throw new Error('canvas');\n }\n\n const diffOptions = {\n ...this.testOptions.imageDiffOptions,\n ...testCase.imageDiffOptions,\n goldenImage: testCase.goldenImage,\n region: getBoundingBoxInPage(canvas)\n };\n\n // Take screenshot and compare\n const result = await globalThis.browserTestDriver_captureAndDiffScreen(diffOptions);\n\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"],"mappings":";SAAQA,UAAU;AAAA,SACVC,oBAAoB;AAY5B,OAAO,MAAMC,kBAAkB,SAASF,UAAU,CAAC;EAGjDG,WAAWA,CAACC,KAA8B,EAAE;IAC1C,KAAK,CAACA,KAAK,CAAC;IAACC,eAAA,oBAHc,KAAK;IAIhC,IAAI,CAACC,WAAW,CAACC,gBAAgB,GAAG,CAAC,CAAC;EACxC;EAESC,YAAYA,CAACC,QAAoC,EAAQ;IAChE,KAAK,CAACD,YAAY,CAACC,QAAQ,CAAC;IAC5B,IAAI,CAACA,QAAQ,CAACC,WAAW,EAAE;MACzB,MAAM,IAAIC,KAAK,cAAAC,MAAA,CAAcH,QAAQ,CAACI,IAAI,iCAA8B;IAC1E;EACF;EAESC,YAAYA,CAAA,EAAY;IAE/B,OAAO,CAAC,IAAI,CAACC,SAAS;EACxB;EAEA,MAAeC,MAAMA,CAACP,QAAoC,EAAiB;IAAA,IAAAQ,qBAAA;IACzE,IAAI,IAAI,CAACF,SAAS,EAAE;MAElB;IACF;IACA,IAAI,CAACA,SAAS,GAAG,IAAI;IAErB,MAAMG,MAAM,IAAAD,qBAAA,GAAG,IAAI,CAACE,eAAe,cAAAF,qBAAA,uBAApBA,qBAAA,CAAsBC,MAAM;IAC3C,IAAI,EAAEA,MAAM,YAAYE,iBAAiB,CAAC,EAAE;MAC1C,MAAM,IAAIT,KAAK,CAAC,QAAQ,CAAC;IAC3B;IAEA,MAAMU,WAAW,GAAG;MAClB,GAAG,IAAI,CAACf,WAAW,CAACC,gBAAgB;MACpC,GAAGE,QAAQ,CAACF,gBAAgB;MAC5BG,WAAW,EAAED,QAAQ,CAACC,WAAW;MACjCY,MAAM,EAAErB,oBAAoB,CAACiB,MAAM;IACrC,CAAC;IAGD,MAAMK,MAAM,GAAG,MAAMC,UAAU,CAACC,sCAAsC,CAACJ,WAAW,CAAC;IAGnF,IAAIE,MAAM,CAACG,OAAO,EAAE;MAClB,IAAI,CAACC,KAAK,CAACJ,MAAM,CAAC;IACpB,CAAC,MAAM;MACL,IAAI,CAACK,KAAK,CAACL,MAAM,CAAC;IACpB;IAEA,IAAI,CAACR,SAAS,GAAG,KAAK;IACtB,IAAI,CAACc,KAAK,EAAE;EACd;AACF"}
|
package/dist/test-runner.d.ts
CHANGED
|
@@ -25,7 +25,7 @@ export declare type TestRunnerProps = {
|
|
|
25
25
|
imageDiffOptions?: any;
|
|
26
26
|
};
|
|
27
27
|
/** Runs an array of test cases */
|
|
28
|
-
export
|
|
28
|
+
export declare class TestRunner {
|
|
29
29
|
device: import("modules/webgl/dist").WebGLDevice;
|
|
30
30
|
props: Record<string, any>;
|
|
31
31
|
isRunning: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-runner.d.ts","sourceRoot":"","sources":["../src/test-runner.ts"],"names":[],"mappings":"AAEA,OAAO,EAAgB,cAAc,EAAC,MAAM,uBAAuB,CAAC;AAGpE,4BAA4B;AAC5B,oBAAY,kBAAkB,GAAG;IAC/B,0CAA0C;IAC1C,IAAI,EAAE,MAAM,CAAC;IACb,qDAAqD;IACrD,YAAY,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IAC1D,wBAAwB;IACxB,QAAQ,EAAE,CAAC,KAAK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KAAK,IAAI,IAAI;IAMb,SAAS,CAAC,cAAc,KAAA,GAAG,IAAI;IA2C/B,aAAa,IAAI,OAAO,CAAC,kBAAkB,CAAC;CAuD7C"}
|
package/dist/test-runner.js
CHANGED
|
@@ -19,7 +19,7 @@ const DEFAULT_TEST_PROPS = {
|
|
|
19
19
|
onTestFail: testCase => console.log("not ok ".concat(testCase.name, " failed")),
|
|
20
20
|
timeout: 2000
|
|
21
21
|
};
|
|
22
|
-
export
|
|
22
|
+
export class TestRunner {
|
|
23
23
|
constructor() {
|
|
24
24
|
let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
25
25
|
_defineProperty(this, "device", webglDevice);
|
package/dist/test-runner.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-runner.js","names":["AnimationLoop","webglDevice","noop","DEFAULT_TEST_CASE","name","onInitialize","onRender","_ref","done","onFinalize","DEFAULT_TEST_PROPS","onTestStart","testCase","console","log","concat","onTestPass","onTestFail","timeout","TestRunner","constructor","props","arguments","length","undefined","_defineProperty","Boolean","window","browserTestDriver_isHeadless","add","testCases","Array","isArray","_testCases","push","run","options","testOptions","Promise","resolve","reject","_animationLoop","device","_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","Object","assign","popState","shift","pushState","initProps","then","userData"],"sources":["../src/test-runner.ts"],"sourcesContent":["// @ts-nocheck TODO remove\n/* eslint-disable no-console */\nimport {AnimationLoop, AnimationProps} from '@luma.gl/webgl-legacy';\nimport {webglDevice} from './create-test-device';\n\n/** Describes a test case */\nexport type TestRunnerTestCase = {\n /** Name of the test case (for logging) */\n name: string;\n /** Initialize the test case. Can return a promise */\n onInitialize: (props: AnimationProps) => Promise<unknown>;\n /** Perform rendering */\n onRender: (props: AnimationProps & {done}) => void;\n /** Clean up after the test case */\n onFinalize: (props: AnimationProps) => void;\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\n/** Options for a TestRunner */\nexport type TestRunnerProps = {\n width?: number;\n height?: number;\n // test lifecycle callback\n onTestStart?: (testCase: TestRunnerTestCase) => void;\n onTestPass?: (testCase: TestRunnerTestCase) => void;\n onTestFail?: (testCase: TestRunnerTestCase) => void;\n /** milliseconds to wait for each test case before aborting */\n timeout?: number;\n maxFramesToRender?: number;\n // HACK - this is for the snapshot test runner\n imageDiffOptions?: any;\n};\n\nconst DEFAULT_TEST_PROPS: Required<TestRunnerProps> = {\n // test lifecycle callback\n onTestStart: (testCase: TestRunnerTestCase) => console.log(`# ${testCase.name}`),\n onTestPass: (testCase: TestRunnerTestCase) => console.log(`ok ${testCase.name} passed`),\n onTestFail: (testCase: TestRunnerTestCase) => console.log(`not ok ${testCase.name} failed`),\n\n // milliseconds to wait for each test case before aborting\n timeout: 2000\n};\n\n/** Runs an array of test cases */\nexport default class TestRunner {\n device = webglDevice;\n props: Record<string, any>;\n isRunning: boolean = false;\n readonly testOptions: Required<TestRunnerProps> = {...DEFAULT_TEST_PROPS};\n readonly _animationProps?: AnimationProps = {};\n private _animationLoop: AnimationLoop | null;\n private _testCases: TestRunnerTestCase[] = [];\n private _testCaseData: any = null;\n\n // @ts-expect-error\n isHeadless: boolean = Boolean(window.browserTestDriver_isHeadless);\n\n /**\n * props\n * AnimationLoop props\n */\n constructor(props: Record<string, any> = {}) {\n this.props = props;\n }\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 this.testOptions = {...this.testOptions, ...options};\n\n return new Promise<void>((resolve, reject) => {\n this._animationLoop = new AnimationLoop({\n // @ts-expect-error TODO\n ...this.props,\n device: this.device,\n onRender: this._onRender.bind(this),\n onFinalize: () => {\n this.isRunning = false;\n resolve();\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 // reject(error);\n });\n }\n\n /* Lifecycle methods for subclassing */\n\n initTestCase(testCase: TestRunnerTestCase) {\n const {animationLoop} = testCase;\n if (animationLoop) {\n testCase.onInitialize = animationLoop.props.onInitialize.bind(animationLoop);\n testCase.onRender = animationLoop.props.onRender.bind(animationLoop);\n testCase.onFinalize = animationLoop.props.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): boolean {\n return true;\n }\n\n assert(testCase: TestRunnerTestCase): void {\n this._pass(testCase);\n this._next();\n }\n\n /* Utilities */\n\n _pass(result: unknown): void {\n this.testOptions.onTestPass(this._currentTestCase, result);\n // this._animationLoop?.stop();\n }\n\n _fail(result: unknown): void {\n this.testOptions.onTestFail(this._currentTestCase, result);\n // this._animationLoop?.stop();\n }\n\n _next(): void {\n this._nextTestCase();\n }\n\n /* Private methods */\n\n _onRender(animationProps): void {\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: AnimationProps = {\n ...animationProps, \n ...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 // try {\n // test case is initialized, render frame\n testCase.onRender(testCaseAnimationProps);\n // } catch {\n // isDone = true;\n // }\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(): Promise<TestRunnerTestCase> {\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 this.device.popState();\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 this.device.pushState();\n\n // aligned with the behavior of AnimationLoop.onInitialized\n // onInitialized could return a plain object or a promise\n const initProps = {\n ...animationProps,\n // tick/time starts from 0 for each test case\n startTime: animationProps.time,\n time: 0,\n tick: 0\n };\n\n // aligned with the behavior of AnimationLoop.onInitialized\n // onInitialized could return a plain object or a promise\n Promise.resolve(testCase.onInitialize(initProps)).then((userData) => {\n this._testCaseData = userData || {};\n });\n\n // invoke user callback\n this.testOptions.onTestStart(testCase);\n }\n return testCase;\n }\n}\n"],"mappings":";AAEA,SAAQA,aAAa,QAAuB,uBAAuB;AAAC,SAC5DC,WAAW;AAcnB,SAASC,IAAIA,CAAA,EAAG,CAAC;AAEjB,MAAMC,iBAAqC,GAAG;EAC5CC,IAAI,EAAE,cAAc;EACpBC,YAAY,EAAEH,IAAI;EAClBI,QAAQ,EAAEC,IAAA;IAAA,IAAC;MAACC;IAAI,CAAC,GAAAD,IAAA;IAAA,OAAKC,IAAI,EAAE;EAAA;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,cAAc,CAACa,IAAI;MACpD,IAAI,CAACE,yBAAyB,GAAGf,cAAc,CAACc,IAAI;MACpD,IAAI,CAAClB,YAAY,CAACzC,QAAQ,CAAC;MAK3B,IAAI,CAAC8B,MAAM,CAACqC,SAAS,EAAE;MAIvB,MAAMC,SAAS,GAAG;QAChB,GAAGvB,cAAc;QAEjBW,SAAS,EAAEX,cAAc,CAACa,IAAI;QAC9BA,IAAI,EAAE,CAAC;QACPC,IAAI,EAAE;MACR,CAAC;MAIDjC,OAAO,CAACC,OAAO,CAAC3B,QAAQ,CAACP,YAAY,CAAC2E,SAAS,CAAC,CAAC,CAACC,IAAI,CAAEC,QAAQ,IAAK;QACnE,IAAI,CAACf,aAAa,GAAGe,QAAQ,IAAI,CAAC,CAAC;MACrC,CAAC,CAAC;MAGF,IAAI,CAAC7C,WAAW,CAAC1B,WAAW,CAACC,QAAQ,CAAC;IACxC;IACA,OAAOA,QAAQ;EACjB;AACF"}
|
|
1
|
+
{"version":3,"file":"test-runner.js","names":["AnimationLoop","webglDevice","noop","DEFAULT_TEST_CASE","name","onInitialize","onRender","_ref","done","onFinalize","DEFAULT_TEST_PROPS","onTestStart","testCase","console","log","concat","onTestPass","onTestFail","timeout","TestRunner","constructor","props","arguments","length","undefined","_defineProperty","Boolean","window","browserTestDriver_isHeadless","add","testCases","Array","isArray","_testCases","push","run","options","testOptions","Promise","resolve","reject","_animationLoop","device","_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","Object","assign","popState","shift","pushState","initProps","then","userData"],"sources":["../src/test-runner.ts"],"sourcesContent":["// @ts-nocheck TODO remove\n/* eslint-disable no-console */\nimport {AnimationLoop, AnimationProps} from '@luma.gl/webgl-legacy';\nimport {webglDevice} from './create-test-device';\n\n/** Describes a test case */\nexport type TestRunnerTestCase = {\n /** Name of the test case (for logging) */\n name: string;\n /** Initialize the test case. Can return a promise */\n onInitialize: (props: AnimationProps) => Promise<unknown>;\n /** Perform rendering */\n onRender: (props: AnimationProps & {done}) => void;\n /** Clean up after the test case */\n onFinalize: (props: AnimationProps) => void;\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\n/** Options for a TestRunner */\nexport type TestRunnerProps = {\n width?: number;\n height?: number;\n // test lifecycle callback\n onTestStart?: (testCase: TestRunnerTestCase) => void;\n onTestPass?: (testCase: TestRunnerTestCase) => void;\n onTestFail?: (testCase: TestRunnerTestCase) => void;\n /** milliseconds to wait for each test case before aborting */\n timeout?: number;\n maxFramesToRender?: number;\n // HACK - this is for the snapshot test runner\n imageDiffOptions?: any;\n};\n\nconst DEFAULT_TEST_PROPS: Required<TestRunnerProps> = {\n // test lifecycle callback\n onTestStart: (testCase: TestRunnerTestCase) => console.log(`# ${testCase.name}`),\n onTestPass: (testCase: TestRunnerTestCase) => console.log(`ok ${testCase.name} passed`),\n onTestFail: (testCase: TestRunnerTestCase) => console.log(`not ok ${testCase.name} failed`),\n\n // milliseconds to wait for each test case before aborting\n timeout: 2000\n};\n\n/** Runs an array of test cases */\nexport class TestRunner {\n device = webglDevice;\n props: Record<string, any>;\n isRunning: boolean = false;\n readonly testOptions: Required<TestRunnerProps> = {...DEFAULT_TEST_PROPS};\n readonly _animationProps?: AnimationProps = {};\n private _animationLoop: AnimationLoop | null;\n private _testCases: TestRunnerTestCase[] = [];\n private _testCaseData: any = null;\n\n // @ts-expect-error\n isHeadless: boolean = Boolean(window.browserTestDriver_isHeadless);\n\n /**\n * props\n * AnimationLoop props\n */\n constructor(props: Record<string, any> = {}) {\n this.props = props;\n }\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 this.testOptions = {...this.testOptions, ...options};\n\n return new Promise<void>((resolve, reject) => {\n this._animationLoop = new AnimationLoop({\n // @ts-expect-error TODO\n ...this.props,\n device: this.device,\n onRender: this._onRender.bind(this),\n onFinalize: () => {\n this.isRunning = false;\n resolve();\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 // reject(error);\n });\n }\n\n /* Lifecycle methods for subclassing */\n\n initTestCase(testCase: TestRunnerTestCase) {\n const {animationLoop} = testCase;\n if (animationLoop) {\n testCase.onInitialize = animationLoop.props.onInitialize.bind(animationLoop);\n testCase.onRender = animationLoop.props.onRender.bind(animationLoop);\n testCase.onFinalize = animationLoop.props.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): boolean {\n return true;\n }\n\n assert(testCase: TestRunnerTestCase): void {\n this._pass(testCase);\n this._next();\n }\n\n /* Utilities */\n\n _pass(result: unknown): void {\n this.testOptions.onTestPass(this._currentTestCase, result);\n // this._animationLoop?.stop();\n }\n\n _fail(result: unknown): void {\n this.testOptions.onTestFail(this._currentTestCase, result);\n // this._animationLoop?.stop();\n }\n\n _next(): void {\n this._nextTestCase();\n }\n\n /* Private methods */\n\n _onRender(animationProps): void {\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: AnimationProps = {\n ...animationProps, \n ...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 // try {\n // test case is initialized, render frame\n testCase.onRender(testCaseAnimationProps);\n // } catch {\n // isDone = true;\n // }\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(): Promise<TestRunnerTestCase> {\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 this.device.popState();\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 this.device.pushState();\n\n // aligned with the behavior of AnimationLoop.onInitialized\n // onInitialized could return a plain object or a promise\n const initProps = {\n ...animationProps,\n // tick/time starts from 0 for each test case\n startTime: animationProps.time,\n time: 0,\n tick: 0\n };\n\n // aligned with the behavior of AnimationLoop.onInitialized\n // onInitialized could return a plain object or a promise\n Promise.resolve(testCase.onInitialize(initProps)).then((userData) => {\n this._testCaseData = userData || {};\n });\n\n // invoke user callback\n this.testOptions.onTestStart(testCase);\n }\n return testCase;\n }\n}\n"],"mappings":";AAEA,SAAQA,aAAa,QAAuB,uBAAuB;AAAC,SAC5DC,WAAW;AAcnB,SAASC,IAAIA,CAAA,EAAG,CAAC;AAEjB,MAAMC,iBAAqC,GAAG;EAC5CC,IAAI,EAAE,cAAc;EACpBC,Y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,KAAK,EAAE;IACxC,IAAIlE,QAAQ,EAAE;MAEZ,IAAI,CAACoC,gBAAgB,GAAGpC,QAAQ;MAChC,IAAI,CAACyD,yBAAyB,GAAGZ,cAAc,CAACa,IAAI;MACpD,IAAI,CAACE,yBAAyB,GAAGf,cAAc,CAACc,IAAI;MACpD,IAAI,CAAClB,YAAY,CAACzC,QAAQ,CAAC;MAK3B,IAAI,CAAC8B,MAAM,CAACqC,SAAS,EAAE;MAIvB,MAAMC,SAAS,GAAG;QAChB,GAAGvB,cAAc;QAEjBW,SAAS,EAAEX,cAAc,CAACa,IAAI;QAC9BA,IAAI,EAAE,CAAC;QACPC,IAAI,EAAE;MACR,CAAC;MAIDjC,OAAO,CAACC,OAAO,CAAC3B,QAAQ,CAACP,YAAY,CAAC2E,SAAS,CAAC,CAAC,CAACC,IAAI,CAAEC,QAAQ,IAAK;QACnE,IAAI,CAACf,aAAa,GAAGe,QAAQ,IAAI,CAAC,CAAC;MACrC,CAAC,CAAC;MAGF,IAAI,CAAC7C,WAAW,CAAC1B,WAAW,CAACC,QAAQ,CAAC;IACxC;IACA,OAAOA,QAAQ;EACjB;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@luma.gl/test-utils",
|
|
3
|
-
"version": "9.0.0-alpha.
|
|
3
|
+
"version": "9.0.0-alpha.21",
|
|
4
4
|
"description": "Automated WebGL testing utilities with Puppeteer and image diffing",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -55,5 +55,5 @@
|
|
|
55
55
|
"engines": {
|
|
56
56
|
"node": ">=16.18.0"
|
|
57
57
|
},
|
|
58
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "7ee95470a6a2f62753201beb0c36b00e37c70455"
|
|
59
59
|
}
|
package/src/index.ts
CHANGED
|
@@ -3,8 +3,8 @@ import './register-devices';
|
|
|
3
3
|
export type {TestRunnerTestCase} from './test-runner';
|
|
4
4
|
export type {SnapshotTestRunnerTestCase} from './snapshot-test-runner';
|
|
5
5
|
|
|
6
|
-
export {
|
|
7
|
-
export {
|
|
6
|
+
export {SnapshotTestRunner} from './snapshot-test-runner';
|
|
7
|
+
export {PerformanceTestRunner} from './performance-test-runner';
|
|
8
8
|
export {createTestDevice, createTestContext, webgl1Device, webgl2Device, webgpuDevice} from './create-test-device';
|
|
9
9
|
export {getTestDevices, getWebGLTestDevices} from './create-test-device';
|
|
10
10
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// luma.gl, MIT license
|
|
2
2
|
|
|
3
3
|
import {Stats, Stat} from '@probe.gl/stats';
|
|
4
|
-
import TestRunner,
|
|
4
|
+
import {TestRunner, TestRunnerProps, TestRunnerTestCase} from './test-runner';
|
|
5
5
|
|
|
6
6
|
export type PerformanceTestRunnerProps = TestRunnerProps;
|
|
7
7
|
|
|
8
|
-
export
|
|
8
|
+
export class PerformanceTestRunner extends TestRunner {
|
|
9
9
|
private _stats: Stats | null = null;
|
|
10
10
|
private _fps: Stat | null = null;
|
|
11
11
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import TestRunner,
|
|
1
|
+
import {TestRunner, TestRunnerProps, TestRunnerTestCase} from './test-runner';
|
|
2
2
|
import {getBoundingBoxInPage} from './utils';
|
|
3
3
|
|
|
4
4
|
/** A snapshot test case */
|
|
@@ -11,7 +11,7 @@ export type SnapshotTestRunnerTestCase = TestRunnerTestCase & {
|
|
|
11
11
|
|
|
12
12
|
export type SnapshotTestRunnerProps = TestRunnerProps;
|
|
13
13
|
|
|
14
|
-
export
|
|
14
|
+
export class SnapshotTestRunner extends TestRunner {
|
|
15
15
|
private isDiffing: boolean = false;
|
|
16
16
|
|
|
17
17
|
constructor(props: SnapshotTestRunnerProps) {
|
package/src/test-runner.ts
CHANGED