@luma.gl/test-utils 9.0.0-alpha.21 → 9.0.0-alpha.23
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/engine/classic-animation-loop.d.ts +137 -0
- package/dist/engine/classic-animation-loop.d.ts.map +1 -0
- package/dist/engine/classic-animation-loop.js +435 -0
- package/dist/engine/classic-animation-loop.js.map +1 -0
- package/dist/index.cjs +461 -14
- package/dist/snapshot-test-runner.d.ts +0 -1
- package/dist/snapshot-test-runner.d.ts.map +1 -1
- package/dist/snapshot-test-runner.js +0 -2
- package/dist/snapshot-test-runner.js.map +1 -1
- package/dist/test-runner.d.ts +11 -5
- package/dist/test-runner.d.ts.map +1 -1
- package/dist/test-runner.js +16 -9
- package/dist/test-runner.js.map +1 -1
- package/package.json +9 -5
- package/src/engine/classic-animation-loop.ts +714 -0
- package/src/snapshot-test-runner.ts +2 -1
- package/src/test-runner.ts +30 -17
package/src/test-runner.ts
CHANGED
|
@@ -1,27 +1,30 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
|
-
/* eslint-disable
|
|
3
|
-
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
import {AnimationProps} from '@luma.gl/engine';
|
|
4
5
|
import {webglDevice} from './create-test-device';
|
|
5
6
|
|
|
7
|
+
// TODO - Replace with new AnimationLoop from `@luma.gl/engine`
|
|
8
|
+
import {ClassicAnimationLoop as AnimationLoop} from './engine/classic-animation-loop';
|
|
9
|
+
|
|
6
10
|
/** Describes a test case */
|
|
7
11
|
export type TestRunnerTestCase = {
|
|
8
12
|
/** Name of the test case (for logging) */
|
|
9
13
|
name: string;
|
|
10
14
|
/** Initialize the test case. Can return a promise */
|
|
11
|
-
onInitialize: (props: AnimationProps) => Promise<
|
|
15
|
+
onInitialize: (props: AnimationProps) => Promise<void | {}>;
|
|
12
16
|
/** Perform rendering */
|
|
13
17
|
onRender: (props: AnimationProps & {done}) => void;
|
|
14
18
|
/** Clean up after the test case */
|
|
15
19
|
onFinalize: (props: AnimationProps) => void;
|
|
20
|
+
animationLoop?: AnimationLoop;
|
|
16
21
|
};
|
|
17
22
|
|
|
18
|
-
function noop() {}
|
|
19
|
-
|
|
20
23
|
const DEFAULT_TEST_CASE: TestRunnerTestCase = {
|
|
21
24
|
name: 'Unnamed test',
|
|
22
|
-
onInitialize:
|
|
25
|
+
onInitialize: async () => {},
|
|
23
26
|
onRender: ({done}) => done(),
|
|
24
|
-
onFinalize:
|
|
27
|
+
onFinalize: () => {}
|
|
25
28
|
};
|
|
26
29
|
|
|
27
30
|
/** Options for a TestRunner */
|
|
@@ -30,8 +33,8 @@ export type TestRunnerProps = {
|
|
|
30
33
|
height?: number;
|
|
31
34
|
// test lifecycle callback
|
|
32
35
|
onTestStart?: (testCase: TestRunnerTestCase) => void;
|
|
33
|
-
onTestPass?: (testCase: TestRunnerTestCase) => void;
|
|
34
|
-
onTestFail?: (testCase: TestRunnerTestCase) => void;
|
|
36
|
+
onTestPass?: (testCase: TestRunnerTestCase, result?: unknown) => void;
|
|
37
|
+
onTestFail?: (testCase: TestRunnerTestCase, error?: unknown) => void;
|
|
35
38
|
/** milliseconds to wait for each test case before aborting */
|
|
36
39
|
timeout?: number;
|
|
37
40
|
maxFramesToRender?: number;
|
|
@@ -40,13 +43,18 @@ export type TestRunnerProps = {
|
|
|
40
43
|
};
|
|
41
44
|
|
|
42
45
|
const DEFAULT_TEST_PROPS: Required<TestRunnerProps> = {
|
|
46
|
+
width: undefined,
|
|
47
|
+
height: undefined,
|
|
48
|
+
|
|
43
49
|
// test lifecycle callback
|
|
44
50
|
onTestStart: (testCase: TestRunnerTestCase) => console.log(`# ${testCase.name}`),
|
|
45
|
-
onTestPass: (testCase: TestRunnerTestCase) => console.log(`ok ${testCase.name} passed`),
|
|
46
|
-
onTestFail: (testCase: TestRunnerTestCase) => console.log(`not ok ${testCase.name} failed`),
|
|
51
|
+
onTestPass: (testCase: TestRunnerTestCase, result?: unknown) => console.log(`ok ${testCase.name} passed`),
|
|
52
|
+
onTestFail: (testCase: TestRunnerTestCase, error?: unknown) => console.log(`not ok ${testCase.name} failed`),
|
|
47
53
|
|
|
48
54
|
// milliseconds to wait for each test case before aborting
|
|
49
|
-
timeout: 2000
|
|
55
|
+
timeout: 2000,
|
|
56
|
+
maxFramesToRender: undefined,
|
|
57
|
+
imageDiffOptions: undefined
|
|
50
58
|
};
|
|
51
59
|
|
|
52
60
|
/** Runs an array of test cases */
|
|
@@ -54,11 +62,17 @@ export class TestRunner {
|
|
|
54
62
|
device = webglDevice;
|
|
55
63
|
props: Record<string, any>;
|
|
56
64
|
isRunning: boolean = false;
|
|
57
|
-
|
|
58
|
-
readonly _animationProps?: AnimationProps
|
|
65
|
+
testOptions: Required<TestRunnerProps> = {...DEFAULT_TEST_PROPS};
|
|
66
|
+
readonly _animationProps?: AnimationProps;
|
|
59
67
|
private _animationLoop: AnimationLoop | null;
|
|
60
68
|
private _testCases: TestRunnerTestCase[] = [];
|
|
61
69
|
private _testCaseData: any = null;
|
|
70
|
+
private _currentTestCase: TestRunnerTestCase | null;
|
|
71
|
+
private _currentTestCaseStartTime: number;
|
|
72
|
+
private _currentTestCaseStartTick: number;
|
|
73
|
+
|
|
74
|
+
// should be defined in snapshot-test-runner
|
|
75
|
+
isDiffing: boolean = false;
|
|
62
76
|
|
|
63
77
|
// @ts-expect-error
|
|
64
78
|
isHeadless: boolean = Boolean(window.browserTestDriver_isHeadless);
|
|
@@ -92,7 +106,6 @@ export class TestRunner {
|
|
|
92
106
|
|
|
93
107
|
return new Promise<void>((resolve, reject) => {
|
|
94
108
|
this._animationLoop = new AnimationLoop({
|
|
95
|
-
// @ts-expect-error TODO
|
|
96
109
|
...this.props,
|
|
97
110
|
device: this.device,
|
|
98
111
|
onRender: this._onRender.bind(this),
|
|
@@ -204,7 +217,7 @@ export class TestRunner {
|
|
|
204
217
|
for (const key in this._testCaseData) {
|
|
205
218
|
const value = this._testCaseData[key];
|
|
206
219
|
if (value && value.delete) {
|
|
207
|
-
value.
|
|
220
|
+
value.destroy();
|
|
208
221
|
}
|
|
209
222
|
}
|
|
210
223
|
this._currentTestCase.onFinalize(Object.assign({}, animationProps, this._testCaseData));
|