summaryrefslogtreecommitdiffstats
path: root/remote/test/puppeteer/tools/mocha-runner/src/types.ts
blob: 01dc4d6be613aab605be88770a1a5fa149e997f7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/**
 * @license
 * Copyright 2022 Google Inc.
 * SPDX-License-Identifier: Apache-2.0
 */

import {z} from 'zod';

import type {RecommendedExpectation} from './utils.js';

export const zPlatform = z.enum(['win32', 'linux', 'darwin']);

export type Platform = z.infer<typeof zPlatform>;

export const zTestSuite = z.object({
  id: z.string(),
  platforms: z.array(zPlatform),
  parameters: z.array(z.string()),
  expectedLineCoverage: z.number(),
});

export type TestSuite = z.infer<typeof zTestSuite>;

export const zTestSuiteFile = z.object({
  testSuites: z.array(zTestSuite),
  parameterDefinitions: z.record(z.any()),
});

export type TestSuiteFile = z.infer<typeof zTestSuiteFile>;

export type TestResult = 'PASS' | 'FAIL' | 'TIMEOUT' | 'SKIP';

export interface TestExpectation {
  testIdPattern: string;
  platforms: NodeJS.Platform[];
  parameters: string[];
  expectations: TestResult[];
}

export interface MochaTestResult {
  fullTitle: string;
  title: string;
  file: string;
  err?: {code: string};
}

export interface MochaResults {
  stats: {tests: number};
  pending: MochaTestResult[];
  passes: MochaTestResult[];
  failures: MochaTestResult[];
  // Added by mocha-runner.
  updates?: RecommendedExpectation[];
  parameters?: string[];
  platform?: string;
  date?: string;
}