[jest-specific-snapshot]: New definition.

This commit is contained in:
Janeene Beeforth 2018-04-07 00:16:20 +10:00
parent db7a840e4f
commit e204ccc77f
4 changed files with 67 additions and 0 deletions

27
types/jest-specific-snapshot/index.d.ts vendored Normal file
View File

@ -0,0 +1,27 @@
// Type definitions for jest-specific-snapshot 0.5
// Project: https://github.com/igor-dv/jest-specific-snapshot#readme
// Definitions by: Janeene Beeforth <https://github.com/dawnmist>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.6
/// <reference types="jest" />
declare global {
namespace jest {
interface Matchers<R> {
toMatchSpecificSnapshot(snapshotFilename: string): R;
}
}
}
/**
* Specify the serializer that should be used by toMatchSpecificSnapshot.
* Note: toMatchSpecificSnapshot ignores the existing jest snapshot serializer settings. If you want to use a custom serializer,
* you need to set it via this addSerializer function.
*/
export function addSerializer(serializer: any): void;
/**
* This is used to create a customized version of toMatchSpecificSnapshot.
*/
export function toMatchSpecificSnapshot(data: any, snapshotFile: string, testName: string): () => { message(): string; pass: boolean; };

View File

@ -0,0 +1,16 @@
import { addSerializer, toMatchSpecificSnapshot } from 'jest-specific-snapshot';
import toJson from 'enzyme-to-json';
expect(100).toMatchSpecificSnapshot('mySnapshotFile.snap');
addSerializer(toJson);
function doSomeThing(received: any) {
return received;
}
expect.extend({
toMatchDecoratedSpecificSnapshot(received, snapshotFile) {
const data = doSomeThing(received);
return toMatchSpecificSnapshot.call(this, data, snapshotFile);
}
});

View File

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

View File

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