Added expect-puppeteer types

This commit is contained in:
Joshua Goldberg
2018-04-04 17:48:24 -07:00
parent 0afd9936a8
commit fa290f099e
4 changed files with 77 additions and 0 deletions
+54
View File
@@ -0,0 +1,54 @@
// Type definitions for expect-puppeteer 2.2
// Project: https://github.com/smooth-code/jest-puppeteer
// Definitions by: Josh Goldberg <https://github.com/JoshuaKGoldberg>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
/// <reference types="jest" />
import { ElementHandle, Page } from "puppeteer";
/**
* Interval at which pageFunctions may be executed.
*/
type ExpectPolling = number | "mutation" | "raf";
/**
* Configures how to poll for an element.
*/
interface ExpectTimingActions {
/**
* An interval at which the pageFunction is executed. Defaults to "raf".
*/
polling?: ExpectPolling;
/**
* Maximum time to wait for in milliseconds. Defaults to 500.
*/
timeout?: number;
}
interface ExpectToClickOptions extends ExpectTimingActions {
/**
* A text or a RegExp to match in element textContent.
*/
text?: string | RegExp;
}
interface ExpectPuppeteer {
toClick(selector: string, options?: ExpectToClickOptions): Promise<void>;
toDisplayDialog(block: () => Promise<void>): Promise<void>;
toFill(selector: string, value: string, options?: ExpectTimingActions): Promise<void>;
toMatch(value: string, options?: ExpectTimingActions): Promise<void>;
toMatchElement(selector: string, value: string, options?: ExpectTimingActions): Promise<void>;
toSelect(selector: string, valueOrText: string, options?: ExpectTimingActions): Promise<void>;
toUploadFile(selector: string, filePath: string, options?: ExpectTimingActions): Promise<void>;
}
declare global {
namespace jest {
interface Matchers<R> extends ExpectPuppeteer { }
}
}
export function expectPuppeteer(instance: ElementHandle | Page): ExpectPuppeteer;
+22
View File
@@ -0,0 +1,22 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"expect-puppeteer-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }