Skip to content

Commit a80ba81

Browse files
committed
fix(test): ensure we add device specs to report
1 parent 61160dd commit a80ba81

File tree

6 files changed

+16
-2
lines changed

6 files changed

+16
-2
lines changed

packages/commands/test/src/__tests__/measurePerformance.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ jest.mock("@perf-profiler/profiler", () => {
1515
mockPerformancePolling.setCallback(onMeasure);
1616
onStartMeasuring();
1717
});
18+
mockedProfiler.detectDeviceRefreshRate = jest.fn(() => 120);
1819

1920
return {
2021
...jest.requireActual("@perf-profiler/profiler"),
@@ -90,6 +91,9 @@ describe("measurePerformance", () => {
9091
],
9192
"name": "TITLE",
9293
"score": 3,
94+
"specs": {
95+
"refreshRate": 120,
96+
},
9397
"status": "SUCCESS",
9498
}
9599
`);

packages/commands/test/src/__tests__/writeResults.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ jest.mock("@perf-profiler/profiler", () => ({
99
profiler: {
1010
...jest.requireActual("@perf-profiler/profiler").profiler,
1111
installProfilerOnDevice: jest.fn(),
12+
detectDeviceRefreshRate: jest.fn(() => 120),
1213
},
1314
}));
1415

packages/commands/test/src/writeReport.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Logger } from "@perf-profiler/logger";
2+
import { profiler } from "@perf-profiler/profiler";
23
import { averageTestCaseResult } from "@perf-profiler/reporter";
34
import {
45
AveragedTestCaseResult,
@@ -26,6 +27,9 @@ export const writeReport = (
2627
measures.length === 0 || measures[measures.length - 1].status === "FAILURE"
2728
? "FAILURE"
2829
: "SUCCESS",
30+
specs: {
31+
refreshRate: profiler.detectDeviceRefreshRate(),
32+
},
2933
};
3034

3135
/**

packages/core/types/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export interface TestCaseResult {
3939
status: TestCaseResultStatus;
4040
iterations: TestCaseIterationResult[];
4141
type?: TestCaseResultType;
42-
specs?: DeviceSpecs;
42+
specs: DeviceSpecs | undefined;
4343
}
4444

4545
export interface AveragedTestCaseResult {
@@ -50,7 +50,7 @@ export interface AveragedTestCaseResult {
5050
average: TestCaseIterationResult;
5151
averageHighCpuUsage: { [processName: string]: number };
5252
type?: TestCaseResultType;
53-
specs?: DeviceSpecs;
53+
specs: DeviceSpecs | undefined;
5454
}
5555

5656
// Shouldn't really be here but @perf-profiler/types is imported by everyone and doesn't contain any logic

packages/core/web-reporter-ui/ReporterView.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ export const ReporterView = ({ measures }: { measures: Measure[] }) => (
129129
status: "SUCCESS",
130130
},
131131
],
132+
// TODO: set specs properly here
133+
specs: undefined,
132134
},
133135
]}
134136
/>

packages/platforms/ios-instruments/src/writeReport.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,9 @@ export const writeReport = (inputFileName: string, outputFileName: string) => {
122122
status: "SUCCESS",
123123
iterations,
124124
type: "IOS_EXPERIMENTAL",
125+
specs: {
126+
refreshRate: FAKE_FPS,
127+
},
125128
};
126129

127130
fs.writeFileSync(outputFileName, JSON.stringify(results, null, 2));

0 commit comments

Comments
 (0)