1/* 2 * Copyright (c) 2021-2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16export const DEFAULT = 0B0000 17 18export const when: when; 19 20export enum TestType { 21 FUNCTION = 0B1, 22 PERFORMANCE = 0B1 << 1, 23 POWER = 0B1 << 2, 24 RELIABILITY = 0B1 << 3, 25 SECURITY = 0B1 << 4, 26 GLOBAL = 0B1 << 5, 27 COMPATIBILITY = 0B1 << 6, 28 USER = 0B1 << 7, 29 STANDARD = 0B1 << 8, 30 SAFETY = 0B1 << 9, 31 RESILIENCE = 0B1 << 10 32} 33 34export enum Size { 35 SMALLTEST = 0B1 << 16, 36 MEDIUMTEST = 0B1 << 17, 37 LARGETEST = 0B1 << 18 38} 39 40export enum Level { 41 LEVEL0 = 0B1 << 24, 42 LEVEL1 = 0B1 << 25, 43 LEVEL2 = 0B1 << 26, 44 LEVEL3 = 0B1 << 27, 45 LEVEL4 = 0B1 << 28 46} 47export { xdescribe, xit, describe, it } from './index'; 48 49 50 51export function beforeItSpecified(testCaseNames: Array<string> | string, callback: Function): void 52 53export function afterItSpecified(testCaseNames: Array<string> | string, callback: Function): void 54 55export function beforeEach(callback: Function): void 56 57export function afterEach(callback: Function): void 58 59export function beforeAll(callback: Function): void 60 61export function afterAll(callback: Function): void 62 63 64export interface Assert { 65 assertClose(expectValue: number, precision: number): void 66 assertContain(expectValue: any): void 67 assertEqual(expectValue: any): void 68 assertFail(): void 69 assertFalse(): void 70 assertTrue(): void 71 assertInstanceOf(expectValue: string): void 72 assertLarger(expectValue: number): void 73 assertLess(expectValue: number): void 74 assertNull(): void 75 assertThrowError(expectValue: string | Function): void 76 assertUndefined(): void 77 assertLargerOrEqual(expectValue: number): void 78 assertLessOrEqual(expectValue: number): void 79 assertNaN(): void 80 assertNegUnlimited(): void 81 assertPosUnlimited(): void 82 not(): Assert; 83 assertDeepEquals(expectValue: any): void 84 assertPromiseIsPending(): Promise<void> 85 assertPromiseIsRejected(): Promise<void> 86 assertPromiseIsRejectedWith(expectValue?: any): Promise<void> 87 assertPromiseIsRejectedWithError(...expectValue): Promise<void> 88 assertPromiseIsResolved(): Promise<void> 89 assertPromiseIsResolvedWith(expectValue?: any): Promise<void> 90 message(msg: string): Assert 91} 92 93export function expect(actualValue?: any): Assert 94 95export class ArgumentMatchers { 96 static any; 97 static anyString; 98 static anyBoolean; 99 static anyNumber; 100 static anyObj; 101 static anyFunction; 102 static matchRegexs(Regex: RegExp): void 103} 104 105declare interface when { 106 afterReturn(value: any): any 107 afterReturnNothing(): undefined 108 afterAction(action: any): any 109 afterThrow(e_msg: string): string 110 (argMatchers?: any): when; 111} 112 113export interface VerificationMode { 114 times(count: Number): void 115 never(): void 116 once(): void 117 atLeast(count: Number): void 118 atMost(count: Number): void 119} 120 121export class MockKit { 122 constructor() 123 mockFunc(obj: Object, func: Function): Function 124 mockObject(obj: Object): Object 125 verify(methodName: String, argsArray: Array<any>): VerificationMode 126 ignoreMock(obj: Object, func: Function): void 127 clear(obj: Object): void 128 clearAll(): void 129} 130 131export class SysTestKit { 132 static getDescribeName(): string; 133 static getItName(): string; 134 static getItAttribute(): TestType | Size | Level 135 static actionStart(tag: string): void 136 static actionEnd(tag: string): void 137 static existKeyword(keyword: string, timeout?: number): boolean 138} 139 140export class Hypium { 141 static setData(data: { [key: string]: any }): void 142 static setTimeConfig(systemTime: any) 143 static hypiumTest(abilityDelegator: any, abilityDelegatorArguments: any, testsuite: Function): void 144 static set(key: string, value: any): void 145 static get(key: string): any 146 static registerAssert(customAssertion: Function): void 147 static unregisterAssert(customAssertion: string | Function): void 148 static hypiumWorkerTest(abilityDelegator: Object, abilityDelegatorArguments: Object, testsuite: Function, workerPort: Object): void; 149 static hypiumInitWorkers(abilityDelegator: Object, scriptURL: string, workerNum: number, params: Object): void; 150}