mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-31 03:02:04 +08:00
Add typings for chai-jest-snapshot
This commit is contained in:
23
types/chai-jest-snapshot/chai-jest-snapshot-tests.ts
Normal file
23
types/chai-jest-snapshot/chai-jest-snapshot-tests.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import chaiJestSnapshot from 'chai-jest-snapshot';
|
||||
import { expect } from 'chai';
|
||||
|
||||
chai.use(chaiJestSnapshot);
|
||||
|
||||
expect({}).to.matchSnapshot();
|
||||
expect({}).to.matchSnapshot(true);
|
||||
expect({}).to.matchSnapshot("filename");
|
||||
expect({}).to.matchSnapshot("filename", "snapshotname");
|
||||
expect({}).to.matchSnapshot("filename", "snapshotname", false);
|
||||
|
||||
const mockContext: Mocha.IBeforeAndAfterContext = <any> {
|
||||
currentTest: {
|
||||
file: 'testfile',
|
||||
fullTitle: () => 'fullTitle'
|
||||
}
|
||||
};
|
||||
|
||||
chaiJestSnapshot.setFileName("filename");
|
||||
chaiJestSnapshot.setTestName("testname");
|
||||
chaiJestSnapshot.configureUsingMochaContext(mockContext);
|
||||
chaiJestSnapshot.resetSnapshotRegistry();
|
||||
chaiJestSnapshot.addSerializer({});
|
||||
63
types/chai-jest-snapshot/index.d.ts
vendored
Normal file
63
types/chai-jest-snapshot/index.d.ts
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
// Type definitions for chai-jest-snapshot 1.3
|
||||
// Project: https://github.com/suchipi/chai-jest-snapshot#readme
|
||||
// Definitions by: Matt Perry <https://github.com/mattvperry>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="chai" />
|
||||
/// <reference types="mocha" />
|
||||
|
||||
declare global {
|
||||
namespace Chai {
|
||||
interface Assertion {
|
||||
/**
|
||||
* Assert that the object matches the snapshot
|
||||
* @param snapshotFilename
|
||||
* @param snapshotName
|
||||
* @param update
|
||||
*/
|
||||
matchSnapshot(snapshotFilename?: string, snapshotName?: string, update?: boolean): Assertion;
|
||||
matchSnapshot(update: boolean): Assertion;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
interface ChaiJestSnapshot {
|
||||
/**
|
||||
* Chai bootstrapper
|
||||
* @param chai
|
||||
* @param utils
|
||||
*/
|
||||
(chai: any, utils: any): void;
|
||||
|
||||
/**
|
||||
* Set snapshot file name
|
||||
* @param filename
|
||||
*/
|
||||
setFileName(filename: string): void;
|
||||
|
||||
/**
|
||||
* Set snapshot test name
|
||||
* @param testname
|
||||
*/
|
||||
setTestName(testname: string): void;
|
||||
|
||||
/**
|
||||
* Configure snapshot name using mocha context
|
||||
* @param context
|
||||
*/
|
||||
configureUsingMochaContext(context: Mocha.IBeforeAndAfterContext): void;
|
||||
|
||||
/**
|
||||
* Reset snapshot registry
|
||||
*/
|
||||
resetSnapshotRegistry(): void;
|
||||
|
||||
/**
|
||||
* Add a serializer plugin
|
||||
* @param serializer
|
||||
*/
|
||||
addSerializer(serializer: any): void;
|
||||
}
|
||||
|
||||
declare var ChaiJestSnapshot: ChaiJestSnapshot;
|
||||
export default ChaiJestSnapshot;
|
||||
22
types/chai-jest-snapshot/tsconfig.json
Normal file
22
types/chai-jest-snapshot/tsconfig.json
Normal 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",
|
||||
"chai-jest-snapshot-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/chai-jest-snapshot/tslint.json
Normal file
1
types/chai-jest-snapshot/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user