Skip to content

Commit

Permalink
all[minor]: Add ability to disable console logs in tests (langchain-a…
Browse files Browse the repository at this point in the history
  • Loading branch information
bracesproul authored Jul 9, 2024
1 parent 9acba0a commit 27d99e8
Show file tree
Hide file tree
Showing 22 changed files with 132 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import { awaitAllCallbacks } from "@langchain/core/callbacks/promises";
import { afterAll, jest } from "@jest/globals";

afterAll(awaitAllCallbacks);

// Allow console.log to be disabled in tests
if (process.env.DISABLE_CONSOLE_LOGS === "true") {
console.log = jest.fn();
}
6 changes: 6 additions & 0 deletions libs/langchain-anthropic/scripts/jest-setup-after-env.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import { awaitAllCallbacks } from "@langchain/core/callbacks/promises";
import { afterAll, jest } from "@jest/globals";

afterAll(awaitAllCallbacks);

// Allow console.log to be disabled in tests
if (process.env.DISABLE_CONSOLE_LOGS === "true") {
console.log = jest.fn();
}
6 changes: 6 additions & 0 deletions libs/langchain-aws/scripts/jest-setup-after-env.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import { awaitAllCallbacks } from "@langchain/core/callbacks/promises";
import { afterAll, jest } from "@jest/globals";

afterAll(awaitAllCallbacks);

// Allow console.log to be disabled in tests
if (process.env.DISABLE_CONSOLE_LOGS === "true") {
console.log = jest.fn();
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import { awaitAllCallbacks } from "@langchain/core/callbacks/promises";
import { afterAll, jest } from "@jest/globals";

afterAll(awaitAllCallbacks);

// Allow console.log to be disabled in tests
if (process.env.DISABLE_CONSOLE_LOGS === "true") {
console.log = jest.fn();
}
6 changes: 6 additions & 0 deletions libs/langchain-azure-openai/scripts/jest-setup-after-env.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import { awaitAllCallbacks } from "@langchain/core/callbacks/promises";
import { afterAll, jest } from "@jest/globals";

afterAll(awaitAllCallbacks);

// Allow console.log to be disabled in tests
if (process.env.DISABLE_CONSOLE_LOGS === "true") {
console.log = jest.fn();
}
6 changes: 6 additions & 0 deletions libs/langchain-baidu-qianfan/scripts/jest-setup-after-env.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import { awaitAllCallbacks } from "@langchain/core/callbacks/promises";
import { afterAll, jest } from "@jest/globals";

afterAll(awaitAllCallbacks);

// Allow console.log to be disabled in tests
if (process.env.DISABLE_CONSOLE_LOGS === "true") {
console.log = jest.fn();
}
6 changes: 6 additions & 0 deletions libs/langchain-cloudflare/scripts/jest-setup-after-env.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import { awaitAllCallbacks } from "@langchain/core/callbacks/promises";
import { afterAll, jest } from "@jest/globals";

afterAll(awaitAllCallbacks);

// Allow console.log to be disabled in tests
if (process.env.DISABLE_CONSOLE_LOGS === "true") {
console.log = jest.fn();
}
6 changes: 6 additions & 0 deletions libs/langchain-cohere/scripts/jest-setup-after-env.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import { awaitAllCallbacks } from "@langchain/core/callbacks/promises";
import { afterAll, jest } from "@jest/globals";

afterAll(awaitAllCallbacks);

// Allow console.log to be disabled in tests
if (process.env.DISABLE_CONSOLE_LOGS === "true") {
console.log = jest.fn();
}
6 changes: 6 additions & 0 deletions libs/langchain-community/scripts/jest-setup-after-env.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import { awaitAllCallbacks } from "@langchain/core/callbacks/promises";
import { afterAll, jest } from "@jest/globals";

afterAll(awaitAllCallbacks);

// Allow console.log to be disabled in tests
if (process.env.DISABLE_CONSOLE_LOGS === "true") {
console.log = jest.fn();
}
6 changes: 6 additions & 0 deletions libs/langchain-exa/scripts/jest-setup-after-env.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import { awaitAllCallbacks } from "@langchain/core/callbacks/promises";
import { afterAll, jest } from "@jest/globals";

afterAll(awaitAllCallbacks);

// Allow console.log to be disabled in tests
if (process.env.DISABLE_CONSOLE_LOGS === "true") {
console.log = jest.fn();
}
6 changes: 6 additions & 0 deletions libs/langchain-google-genai/scripts/jest-setup-after-env.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import { awaitAllCallbacks } from "@langchain/core/callbacks/promises";
import { afterAll, jest } from "@jest/globals";

afterAll(awaitAllCallbacks);

// Allow console.log to be disabled in tests
if (process.env.DISABLE_CONSOLE_LOGS === "true") {
console.log = jest.fn();
}
6 changes: 6 additions & 0 deletions libs/langchain-groq/scripts/jest-setup-after-env.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import { awaitAllCallbacks } from "@langchain/core/callbacks/promises";
import { afterAll, jest } from "@jest/globals";

afterAll(awaitAllCallbacks);

// Allow console.log to be disabled in tests
if (process.env.DISABLE_CONSOLE_LOGS === "true") {
console.log = jest.fn();
}
6 changes: 6 additions & 0 deletions libs/langchain-mistralai/scripts/jest-setup-after-env.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import { awaitAllCallbacks } from "@langchain/core/callbacks/promises";
import { afterAll, jest } from "@jest/globals";

afterAll(awaitAllCallbacks);

// Allow console.log to be disabled in tests
if (process.env.DISABLE_CONSOLE_LOGS === "true") {
console.log = jest.fn();
}
6 changes: 6 additions & 0 deletions libs/langchain-mixedbread-ai/scripts/jest-setup-after-env.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import { awaitAllCallbacks } from "@langchain/core/callbacks/promises";
import { afterAll, jest } from "@jest/globals";

afterAll(awaitAllCallbacks);

// Allow console.log to be disabled in tests
if (process.env.DISABLE_CONSOLE_LOGS === "true") {
console.log = jest.fn();
}
6 changes: 6 additions & 0 deletions libs/langchain-mongodb/scripts/jest-setup-after-env.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import { awaitAllCallbacks } from "@langchain/core/callbacks/promises";
import { afterAll, jest } from "@jest/globals";

afterAll(awaitAllCallbacks);

// Allow console.log to be disabled in tests
if (process.env.DISABLE_CONSOLE_LOGS === "true") {
console.log = jest.fn();
}
6 changes: 6 additions & 0 deletions libs/langchain-nomic/scripts/jest-setup-after-env.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import { awaitAllCallbacks } from "@langchain/core/callbacks/promises";
import { afterAll, jest } from "@jest/globals";

afterAll(awaitAllCallbacks);

// Allow console.log to be disabled in tests
if (process.env.DISABLE_CONSOLE_LOGS === "true") {
console.log = jest.fn();
}
6 changes: 6 additions & 0 deletions libs/langchain-pinecone/scripts/jest-setup-after-env.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import { awaitAllCallbacks } from "@langchain/core/callbacks/promises";
import { afterAll, jest } from "@jest/globals";

afterAll(awaitAllCallbacks);

// Allow console.log to be disabled in tests
if (process.env.DISABLE_CONSOLE_LOGS === "true") {
console.log = jest.fn();
}
6 changes: 6 additions & 0 deletions libs/langchain-qdrant/scripts/jest-setup-after-env.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import { awaitAllCallbacks } from "@langchain/core/callbacks/promises";
import { afterAll, jest } from "@jest/globals";

afterAll(awaitAllCallbacks);

// Allow console.log to be disabled in tests
if (process.env.DISABLE_CONSOLE_LOGS === "true") {
console.log = jest.fn();
}
6 changes: 6 additions & 0 deletions libs/langchain-redis/scripts/jest-setup-after-env.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import { awaitAllCallbacks } from "@langchain/core/callbacks/promises";
import { afterAll, jest } from "@jest/globals";

afterAll(awaitAllCallbacks);

// Allow console.log to be disabled in tests
if (process.env.DISABLE_CONSOLE_LOGS === "true") {
console.log = jest.fn();
}
6 changes: 6 additions & 0 deletions libs/langchain-standard-tests/scripts/jest-setup-after-env.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import { awaitAllCallbacks } from "@langchain/core/callbacks/promises";
import { afterAll, jest } from "@jest/globals";

afterAll(awaitAllCallbacks);

// Allow console.log to be disabled in tests
if (process.env.DISABLE_CONSOLE_LOGS === "true") {
console.log = jest.fn();
}
6 changes: 6 additions & 0 deletions libs/langchain-textsplitters/scripts/jest-setup-after-env.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import { awaitAllCallbacks } from "@langchain/core/callbacks/promises";
import { afterAll, jest } from "@jest/globals";

afterAll(awaitAllCallbacks);

// Allow console.log to be disabled in tests
if (process.env.DISABLE_CONSOLE_LOGS === "true") {
console.log = jest.fn();
}
6 changes: 6 additions & 0 deletions libs/langchain-weaviate/scripts/jest-setup-after-env.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import { awaitAllCallbacks } from "@langchain/core/callbacks/promises";
import { afterAll, jest } from "@jest/globals";

afterAll(awaitAllCallbacks);

// Allow console.log to be disabled in tests
if (process.env.DISABLE_CONSOLE_LOGS === "true") {
console.log = jest.fn();
}

0 comments on commit 27d99e8

Please sign in to comment.