langchain.js
    Preparing search index...

    Function wrapJest

    • Dynamically wrap original Jest imports.

      This may be necessary to ensure you are wrapping the correct Jest version if you are using a monorepo whose workspaces use multiple versions of Jest.

      Parameters

      • originalJestMethods: Record<string, unknown>

        The original Jest imports to wrap.

      Returns {
          describe: LangSmithJestlikeDescribeWrapper & {
              concurrent: LangSmithJestlikeDescribeWrapper;
              only: LangSmithJestlikeDescribeWrapper;
              skip: LangSmithJestlikeDescribeWrapper;
          };
          expect: Expect;
          it: <
              I extends Record<string, any> = Record<string, any>,
              O extends Record<string, any> = Record<string, any>,
          >(
              name: string,
              lsParams: LangSmithJestlikeWrapperParams<I, O>,
              testFn: LangSmithJestlikeTestFunction<I, O>,
              timeout?: number,
          ) => void & {
              concurrent: <
                  I extends Record<string, any> = Record<string, any>,
                  O extends Record<string, any> = Record<string, any>,
              >(
                  name: string,
                  lsParams: LangSmithJestlikeWrapperParams<I, O>,
                  testFn: LangSmithJestlikeTestFunction<I, O>,
                  timeout?: number,
              ) => void & {
                  each: <I extends KVMap, O extends KVMap>(
                      table: (
                          { id?: string; inputs: I; referenceOutputs?: O } & Record<
                              string,
                              any,
                          >
                      )[],
                      config?: LangSmithJestlikeWrapperConfig,
                  ) => (
                      name: string,
                      fn: LangSmithJestlikeTestFunction<I, O>,
                      timeout?: number,
                  ) => void;
                  only: <
                      I extends Record<string, any> = Record<string, any>,
                      O extends Record<string, any> = Record<string, any>,
                  >(
                      name: string,
                      lsParams: LangSmithJestlikeWrapperParams<I, O>,
                      testFn: LangSmithJestlikeTestFunction<I, O>,
                      timeout?: number,
                  ) => void & {
                      each: <I extends KVMap, O extends KVMap>(
                          table: (
                              { id?: ...; inputs: ...; referenceOutputs?: ... } & Record<
                                  (...),
                                  (...),
                              >
                          )[],
                          config?: LangSmithJestlikeWrapperConfig,
                      ) => (
                          name: string,
                          fn: LangSmithJestlikeTestFunction<I, O>,
                          timeout?: number,
                      ) => void;
                  };
                  skip: <
                      I extends Record<string, any> = Record<string, any>,
                      O extends Record<string, any> = Record<string, any>,
                  >(
                      name: string,
                      lsParams: LangSmithJestlikeWrapperParams<I, O>,
                      testFn: LangSmithJestlikeTestFunction<I, O>,
                      timeout?: number,
                  ) => void & {
                      each: <I extends KVMap, O extends KVMap>(
                          table: (
                              { id?: ...; inputs: ...; referenceOutputs?: ... } & Record<
                                  (...),
                                  (...),
                              >
                          )[],
                          config?: LangSmithJestlikeWrapperConfig,
                      ) => (
                          name: string,
                          fn: LangSmithJestlikeTestFunction<I, O>,
                          timeout?: number,
                      ) => void;
                  };
              };
              each: <I extends KVMap, O extends KVMap>(
                  table: (
                      { id?: string; inputs: I; referenceOutputs?: O } & Record<
                          string,
                          any,
                      >
                  )[],
                  config?: LangSmithJestlikeWrapperConfig,
              ) => (
                  name: string,
                  fn: LangSmithJestlikeTestFunction<I, O>,
                  timeout?: number,
              ) => void;
              only: <
                  I extends Record<string, any> = Record<string, any>,
                  O extends Record<string, any> = Record<string, any>,
              >(
                  name: string,
                  lsParams: LangSmithJestlikeWrapperParams<I, O>,
                  testFn: LangSmithJestlikeTestFunction<I, O>,
                  timeout?: number,
              ) => void & {
                  each: <I extends KVMap, O extends KVMap>(
                      table: (
                          { id?: string; inputs: I; referenceOutputs?: O } & Record<
                              string,
                              any,
                          >
                      )[],
                      config?: LangSmithJestlikeWrapperConfig,
                  ) => (
                      name: string,
                      fn: LangSmithJestlikeTestFunction<I, O>,
                      timeout?: number,
                  ) => void;
              };
              skip: <
                  I extends Record<string, any> = Record<string, any>,
                  O extends Record<string, any> = Record<string, any>,
              >(
                  name: string,
                  lsParams: LangSmithJestlikeWrapperParams<I, O>,
                  testFn: LangSmithJestlikeTestFunction<I, O>,
                  timeout?: number,
              ) => void & {
                  each: <I extends KVMap, O extends KVMap>(
                      table: (
                          { id?: string; inputs: I; referenceOutputs?: O } & Record<
                              string,
                              any,
                          >
                      )[],
                      config?: LangSmithJestlikeWrapperConfig,
                  ) => (
                      name: string,
                      fn: LangSmithJestlikeTestFunction<I, O>,
                      timeout?: number,
                  ) => void;
              };
          };
          logFeedback: (
              feedback: SimpleEvaluationResult,
              config?: { sourceRunId?: string },
          ) => void;
          logOutputs: (output: Record<string, unknown>) => void;
          test: <
              I extends Record<string, any> = Record<string, any>,
              O extends Record<string, any> = Record<string, any>,
          >(
              name: string,
              lsParams: LangSmithJestlikeWrapperParams<I, O>,
              testFn: LangSmithJestlikeTestFunction<I, O>,
              timeout?: number,
          ) => void & {
              concurrent: <
                  I extends Record<string, any> = Record<string, any>,
                  O extends Record<string, any> = Record<string, any>,
              >(
                  name: string,
                  lsParams: LangSmithJestlikeWrapperParams<I, O>,
                  testFn: LangSmithJestlikeTestFunction<I, O>,
                  timeout?: number,
              ) => void & {
                  each: <I extends KVMap, O extends KVMap>(
                      table: (
                          { id?: string; inputs: I; referenceOutputs?: O } & Record<
                              string,
                              any,
                          >
                      )[],
                      config?: LangSmithJestlikeWrapperConfig,
                  ) => (
                      name: string,
                      fn: LangSmithJestlikeTestFunction<I, O>,
                      timeout?: number,
                  ) => void;
                  only: <
                      I extends Record<string, any> = Record<string, any>,
                      O extends Record<string, any> = Record<string, any>,
                  >(
                      name: string,
                      lsParams: LangSmithJestlikeWrapperParams<I, O>,
                      testFn: LangSmithJestlikeTestFunction<I, O>,
                      timeout?: number,
                  ) => void & {
                      each: <I extends KVMap, O extends KVMap>(
                          table: (
                              { id?: ...; inputs: ...; referenceOutputs?: ... } & Record<
                                  (...),
                                  (...),
                              >
                          )[],
                          config?: LangSmithJestlikeWrapperConfig,
                      ) => (
                          name: string,
                          fn: LangSmithJestlikeTestFunction<I, O>,
                          timeout?: number,
                      ) => void;
                  };
                  skip: <
                      I extends Record<string, any> = Record<string, any>,
                      O extends Record<string, any> = Record<string, any>,
                  >(
                      name: string,
                      lsParams: LangSmithJestlikeWrapperParams<I, O>,
                      testFn: LangSmithJestlikeTestFunction<I, O>,
                      timeout?: number,
                  ) => void & {
                      each: <I extends KVMap, O extends KVMap>(
                          table: (
                              { id?: ...; inputs: ...; referenceOutputs?: ... } & Record<
                                  (...),
                                  (...),
                              >
                          )[],
                          config?: LangSmithJestlikeWrapperConfig,
                      ) => (
                          name: string,
                          fn: LangSmithJestlikeTestFunction<I, O>,
                          timeout?: number,
                      ) => void;
                  };
              };
              each: <I extends KVMap, O extends KVMap>(
                  table: (
                      { id?: string; inputs: I; referenceOutputs?: O } & Record<
                          string,
                          any,
                      >
                  )[],
                  config?: LangSmithJestlikeWrapperConfig,
              ) => (
                  name: string,
                  fn: LangSmithJestlikeTestFunction<I, O>,
                  timeout?: number,
              ) => void;
              only: <
                  I extends Record<string, any> = Record<string, any>,
                  O extends Record<string, any> = Record<string, any>,
              >(
                  name: string,
                  lsParams: LangSmithJestlikeWrapperParams<I, O>,
                  testFn: LangSmithJestlikeTestFunction<I, O>,
                  timeout?: number,
              ) => void & {
                  each: <I extends KVMap, O extends KVMap>(
                      table: (
                          { id?: string; inputs: I; referenceOutputs?: O } & Record<
                              string,
                              any,
                          >
                      )[],
                      config?: LangSmithJestlikeWrapperConfig,
                  ) => (
                      name: string,
                      fn: LangSmithJestlikeTestFunction<I, O>,
                      timeout?: number,
                  ) => void;
              };
              skip: <
                  I extends Record<string, any> = Record<string, any>,
                  O extends Record<string, any> = Record<string, any>,
              >(
                  name: string,
                  lsParams: LangSmithJestlikeWrapperParams<I, O>,
                  testFn: LangSmithJestlikeTestFunction<I, O>,
                  timeout?: number,
              ) => void & {
                  each: <I extends KVMap, O extends KVMap>(
                      table: (
                          { id?: string; inputs: I; referenceOutputs?: O } & Record<
                              string,
                              any,
                          >
                      )[],
                      config?: LangSmithJestlikeWrapperConfig,
                  ) => (
                      name: string,
                      fn: LangSmithJestlikeTestFunction<I, O>,
                      timeout?: number,
                  ) => void;
              };
          };
          toBeAbsoluteCloseTo: (
              received: string,
              expected: string,
              options?: AbsoluteCloseToMatcherOptions,
          ) => Promise<{ message: () => string; pass: boolean }>;
          toBeRelativeCloseTo: (
              received: string,
              expected: string,
              options?: RelativeCloseToMatcherOptions,
          ) => Promise<{ message: () => string; pass: boolean }>;
          toBeSemanticCloseTo: (
              received: string,
              expected: string,
              options: SemanticCloseToMatcherOptions,
          ) => Promise<{ message: () => string; pass: boolean }>;
          wrapEvaluator: <
              I,
              O extends SimpleEvaluationResult | SimpleEvaluationResult[],
          >(
              evaluator: (input: I) => O | Promise<O>,
          ) => (
              input: I,
              config?: Partial<RunTreeConfig> & { runId?: string },
          ) => Promise<O>;
      }

      The wrapped Jest imports. See https://docs.smith.langchain.com/evaluation/how_to_guides/vitest_jest for more details.