mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
[jest-specific-snapshot]: New definition.
This commit is contained in:
parent
db7a840e4f
commit
e204ccc77f
27
types/jest-specific-snapshot/index.d.ts
vendored
Normal file
27
types/jest-specific-snapshot/index.d.ts
vendored
Normal 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; };
|
||||
16
types/jest-specific-snapshot/jest-specific-snapshot-tests.ts
Normal file
16
types/jest-specific-snapshot/jest-specific-snapshot-tests.ts
Normal 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);
|
||||
}
|
||||
});
|
||||
23
types/jest-specific-snapshot/tsconfig.json
Normal file
23
types/jest-specific-snapshot/tsconfig.json
Normal 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"
|
||||
]
|
||||
}
|
||||
1
types/jest-specific-snapshot/tslint.json
Normal file
1
types/jest-specific-snapshot/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user