added types for chai-snapshot-matcher (#48130)

* added types for chai-snapshot-matcher

* added missing overload and optional params
This commit is contained in:
Tomasz Pluskiewicz 2020-09-24 22:49:15 +02:00 committed by GitHub
parent aa5ac1d7ab
commit f4cab83772
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 68 additions and 0 deletions

View File

@ -0,0 +1,19 @@
import chai = require('chai');
const { expect } = chai;
const context: Mocha.Context = <any> {};
expect('foo').to.matchSnapshot(context);
expect('foo').to.matchSnapshot(context, 'hint');
expect('foo').to.matchSpecificSnapshot(context);
expect('foo').to.matchSpecificSnapshot(context, { hint: "(hint)" });
expect('foo').to.matchSpecificSnapshot(context, { name: "snapshot with a specific name" });
expect('foo').to.matchSpecificSnapshot(context, { folder: "Examples" });
expect('foo').to.matchSpecificSnapshot(context, { snapshotPath: "/Users/my.user/Downloads/MySnapshots/" });
expect('foo').to.matchSpecificSnapshot(context, {
hint: "(hint)",
name: "snapshot with a specific name",
folder: "Examples",
snapshotPath: "/Users/my.user/Downloads/MySnapshots/"
});

25
types/chai-snapshot-matcher/index.d.ts vendored Normal file
View File

@ -0,0 +1,25 @@
// Type definitions for chai-snapshot-matcher 1.0
// Project: https://github.com/tlameiras/chai-snapshot#readme
// Definitions by: tpluscode <https://github.com/tpluscode>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 3.0
/// <reference types="chai" />
import { Context } from 'mocha';
declare global {
namespace Chai {
interface Assertion {
matchSnapshot(that: Context, hint?: string): void;
matchSpecificSnapshot(that: Context, options?: {
hint?: string;
name?: string;
folder?: string;
snapshotPath?: string;
}): void;
}
}
}
export {};

View File

@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"chai-snapshot-matcher-tests.ts"
]
}

View File

@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }