first commit

This commit is contained in:
2026-09-08 20:28:54 +08:00
commit 2ada8d3d5a
37380 changed files with 4886169 additions and 0 deletions
+61
View File
@@ -0,0 +1,61 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import { Config } from '@jest/types';
export declare type SnapshotStateOptions = {
updateSnapshot: Config.SnapshotUpdateState;
getPrettier: () => null | typeof import('prettier');
getBabelTraverse: () => Function;
expand?: boolean;
};
export declare type SnapshotMatchOptions = {
testName: string;
received: unknown;
key?: string;
inlineSnapshot?: string;
isInline: boolean;
error?: Error;
};
declare type SnapshotReturnOptions = {
actual: string;
count: number;
expected?: string;
key: string;
pass: boolean;
};
declare type SaveStatus = {
deleted: boolean;
saved: boolean;
};
export default class SnapshotState {
private _counters;
private _dirty;
private _index;
private _updateSnapshot;
private _snapshotData;
private _initialData;
private _snapshotPath;
private _inlineSnapshots;
private _uncheckedKeys;
private _getBabelTraverse;
private _getPrettier;
added: number;
expand: boolean;
matched: number;
unmatched: number;
updated: number;
constructor(snapshotPath: Config.Path, options: SnapshotStateOptions);
markSnapshotsAsCheckedForTest(testName: string): void;
private _addSnapshot;
clear(): void;
save(): SaveStatus;
getUncheckedCount(): number;
getUncheckedKeys(): Array<string>;
removeUncheckedKeys(): void;
match({ testName, received, key, inlineSnapshot, isInline, error, }: SnapshotMatchOptions): SnapshotReturnOptions;
fail(testName: string, _received: unknown, key?: string): string;
}
export {};
+15
View File
@@ -0,0 +1,15 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
export declare const aForeground2 = 90;
export declare const aBackground2 = 225;
export declare const bForeground2 = 23;
export declare const bBackground2 = 195;
export declare type RGB = [number, number, number];
export declare const aForeground3: RGB;
export declare const aBackground3: RGB;
export declare const bForeground3: RGB;
export declare const bBackground3: RGB;
+7
View File
@@ -0,0 +1,7 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
export declare const dedentLines: (input: string[]) => string[] | null;
+105
View File
@@ -0,0 +1,105 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import { Config } from '@jest/types';
import { SnapshotResolver as JestSnapshotResolver } from './snapshot_resolver';
import SnapshotState from './State';
import { Context } from './types';
import * as utils from './utils';
declare const JestSnapshot: {
EXTENSION: string;
SnapshotState: typeof SnapshotState;
addSerializer: (plugin: import("pretty-format/build/types").Plugin) => void;
buildSnapshotResolver: (config: Config.ProjectConfig) => JestSnapshotResolver;
cleanup: (hasteFS: import("jest-haste-map/build/HasteFS").default, update: Config.SnapshotUpdateState, snapshotResolver: JestSnapshotResolver, testPathIgnorePatterns?: string[] | undefined) => {
filesRemoved: number;
filesRemovedList: string[];
};
getSerializers: () => import("pretty-format/build/types").Plugins;
isSnapshotPath: (path: string) => boolean;
toMatchInlineSnapshot: (this: Context, received: any, propertiesOrSnapshot?: string | object | undefined, inlineSnapshot?: string | undefined) => {
message: () => string;
name: string;
pass: boolean;
actual?: undefined;
expected?: undefined;
} | {
message: () => string;
pass: boolean;
name?: undefined;
actual?: undefined;
expected?: undefined;
} | {
actual: string;
expected: string | undefined;
message: () => string;
name: string;
pass: boolean;
};
toMatchSnapshot: (this: Context, received: any, propertiesOrHint?: string | object | undefined, hint?: string | undefined) => {
message: () => string;
name: string;
pass: boolean;
actual?: undefined;
expected?: undefined;
} | {
message: () => string;
pass: boolean;
name?: undefined;
actual?: undefined;
expected?: undefined;
} | {
actual: string;
expected: string | undefined;
message: () => string;
name: string;
pass: boolean;
};
toThrowErrorMatchingInlineSnapshot: (this: Context, received: any, inlineSnapshot?: string | undefined, fromPromise?: boolean | undefined) => {
message: () => string;
name: string;
pass: boolean;
actual?: undefined;
expected?: undefined;
} | {
message: () => string;
pass: boolean;
name?: undefined;
actual?: undefined;
expected?: undefined;
} | {
actual: string;
expected: string | undefined;
message: () => string;
name: string;
pass: boolean;
};
toThrowErrorMatchingSnapshot: (this: Context, received: any, hint: string | undefined, fromPromise: boolean) => {
message: () => string;
name: string;
pass: boolean;
actual?: undefined;
expected?: undefined;
} | {
message: () => string;
pass: boolean;
name?: undefined;
actual?: undefined;
expected?: undefined;
} | {
actual: string;
expected: string | undefined;
message: () => string;
name: string;
pass: boolean;
};
utils: typeof utils;
};
declare namespace JestSnapshot {
type SnapshotResolver = JestSnapshotResolver;
type SnapshotStateType = SnapshotState;
}
export = JestSnapshot;
+12
View File
@@ -0,0 +1,12 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import { Frame } from 'jest-message-util';
export declare type InlineSnapshot = {
snapshot: string;
frame: Frame;
};
export declare function saveInlineSnapshots(snapshots: Array<InlineSnapshot>, prettier: typeof import('prettier') | null, babelTraverse: Function): void;
+11
View File
@@ -0,0 +1,11 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import { NewPlugin } from 'pretty-format';
export declare const serialize: NewPlugin['serialize'];
export declare const test: NewPlugin['test'];
declare const plugin: NewPlugin;
export default plugin;
+8
View File
@@ -0,0 +1,8 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
export declare const addSerializer: (plugin: import("pretty-format/build/types").Plugin) => void;
export declare const getSerializers: () => import("pretty-format/build/types").Plugins;
+22
View File
@@ -0,0 +1,22 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import chalk = require('chalk');
import { DiffOptionsColor } from 'jest-diff';
import { MatchSnapshotConfig } from './types';
export declare const getSnapshotColorForChalkInstance: (chalkInstance: chalk.Chalk) => DiffOptionsColor;
export declare const getReceivedColorForChalkInstance: (chalkInstance: chalk.Chalk) => DiffOptionsColor;
export declare const aSnapshotColor: DiffOptionsColor;
export declare const bReceivedColor: DiffOptionsColor;
export declare const noColor: (string: string) => string;
export declare const HINT_ARG = "hint";
export declare const SNAPSHOT_ARG = "snapshot";
export declare const PROPERTIES_ARG = "properties";
export declare const matcherHintFromConfig: ({ context: { isNot, promise }, hint, inlineSnapshot, matcherName, properties, }: MatchSnapshotConfig, isUpdatable: boolean) => string;
export declare const printExpected: (val: unknown) => string;
export declare const printReceived: (val: unknown) => string;
export declare const printPropertiesAndReceived: (properties: object, received: object, expand: boolean) => string;
export declare const printSnapshotAndReceived: (a: string, b: string, received: unknown, expand: boolean) => string;
+16
View File
@@ -0,0 +1,16 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import { Config } from '@jest/types';
export declare type SnapshotResolver = {
testPathForConsistencyCheck: string;
resolveSnapshotPath(testPath: Config.Path, extension?: string): Config.Path;
resolveTestPath(snapshotPath: Config.Path, extension?: string): Config.Path;
};
export declare const EXTENSION = "snap";
export declare const DOT_EXTENSION: string;
export declare const isSnapshotPath: (path: string) => boolean;
export declare const buildSnapshotResolver: (config: Config.ProjectConfig) => SnapshotResolver;
+21
View File
@@ -0,0 +1,21 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import { MatcherState } from 'expect';
import SnapshotState from './State';
export declare type Context = MatcherState & {
snapshotState: SnapshotState;
};
export declare type MatchSnapshotConfig = {
context: Context;
hint?: string;
inlineSnapshot?: string;
isInline: boolean;
matcherName: string;
properties?: object;
received: any;
};
export declare type SnapshotData = Record<string, string>;
+26
View File
@@ -0,0 +1,26 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import { Config } from '@jest/types';
export declare const SNAPSHOT_VERSION = "1";
export declare const SNAPSHOT_GUIDE_LINK = "https://goo.gl/fbAQLP";
export declare const SNAPSHOT_VERSION_WARNING: string;
export declare const testNameToKey: (testName: string, count: number) => string;
export declare const keyToTestName: (key: string) => string;
export declare const getSnapshotData: (snapshotPath: string, update: Config.SnapshotUpdateState) => {
data: Record<string, string>;
dirty: boolean;
};
export declare const addExtraLineBreaks: (string: string) => string;
export declare const removeExtraLineBreaks: (string: string) => string;
export declare const removeLinesBeforeExternalMatcherTrap: (stack: string) => string;
export declare const serialize: (val: unknown, indent?: number) => string;
export declare const minify: (val: unknown) => string;
export declare const deserializeString: (stringified: string) => string;
export declare const escapeBacktickString: (str: string) => string;
export declare const ensureDirectoryExists: (filePath: string) => void;
export declare const saveSnapshotFile: (snapshotData: Record<string, string>, snapshotPath: string) => void;
export declare const deepMerge: (target: any, source: any) => any;