diff --git a/.github/workflows/build-node-wrapper/action.yml b/.github/workflows/build-node-wrapper/action.yml index 0b06460f2d..8cb1e511e8 100644 --- a/.github/workflows/build-node-wrapper/action.yml +++ b/.github/workflows/build-node-wrapper/action.yml @@ -76,9 +76,9 @@ runs: shell: bash working-directory: ./node run: | - rm -rf node_modules && npm install --frozen-lockfile + rm -rf node_modules && rm -rf package-lock.json && npm install cd rust-client - npm install --frozen-lockfile + rm -rf node_modules && rm -rf package-lock.json && npm install - name: Build shell: bash diff --git a/node/jest.config.js b/node/jest.config.js index e73e7ce439..416608cdcb 100644 --- a/node/jest.config.js +++ b/node/jest.config.js @@ -1,7 +1,9 @@ /* eslint no-undef: off */ module.exports = { preset: "ts-jest", - transform: { "^.+\\.ts?$": "ts-jest" }, + transform: { + "^.+\\.(t|j)s$": ["ts-jest", { isolatedModules: true }], + }, testEnvironment: "node", testRegex: "/tests/.*\\.(test|spec)?\\.(ts|tsx)$", moduleFileExtensions: [ diff --git a/node/tests/AsyncClient.test.ts b/node/tests/AsyncClient.test.ts index 6d0d3b4246..451a3ff3ec 100644 --- a/node/tests/AsyncClient.test.ts +++ b/node/tests/AsyncClient.test.ts @@ -5,6 +5,7 @@ import { afterAll, afterEach, beforeAll, describe } from "@jest/globals"; import { AsyncClient } from "glide-rs"; import RedisServer from "redis-server"; +import { Logger } from ".."; import { runCommonTests } from "./SharedTests"; import { flushallOnPort } from "./TestUtilities"; /* eslint-disable @typescript-eslint/no-require-imports */ @@ -16,6 +17,8 @@ describe("AsyncClient", () => { let server: RedisServer; let port: number; beforeAll(async () => { + Logger.init("error"); + Logger.setLoggerConfig("error"); port = await FreePort(PORT_NUMBER).then( ([free_port]: number[]) => free_port, ); diff --git a/node/tests/GlideClient.test.ts b/node/tests/GlideClient.test.ts index ba970eeab2..c81b43539e 100644 --- a/node/tests/GlideClient.test.ts +++ b/node/tests/GlideClient.test.ts @@ -21,6 +21,7 @@ import { GlideRecord, GlideString, ListDirection, + Logger, ProtocolVersion, RequestError, Script, @@ -56,6 +57,8 @@ describe("GlideClient", () => { let cluster: ValkeyCluster; let client: GlideClient; beforeAll(async () => { + Logger.init("error"); + Logger.setLoggerConfig("error"); const standaloneAddresses = parseCommandLineArgs()["standalone-endpoints"]; cluster = standaloneAddresses diff --git a/node/tests/GlideClientInternals.test.ts b/node/tests/GlideClientInternals.test.ts index 9d8f093d0a..28901a013e 100644 --- a/node/tests/GlideClientInternals.test.ts +++ b/node/tests/GlideClientInternals.test.ts @@ -46,7 +46,8 @@ import { convertStringArrayToBuffer } from "./TestUtilities"; const { RequestType, CommandRequest } = command_request; beforeAll(() => { - Logger.init("info"); + Logger.init("error"); + Logger.setLoggerConfig("error"); }); enum ResponseType { diff --git a/node/tests/GlideClusterClient.test.ts b/node/tests/GlideClusterClient.test.ts index f605271bb0..35cdf91714 100644 --- a/node/tests/GlideClusterClient.test.ts +++ b/node/tests/GlideClusterClient.test.ts @@ -26,6 +26,7 @@ import { GlideReturnType, InfoOptions, ListDirection, + Logger, ProtocolVersion, RequestError, Routes, @@ -64,6 +65,8 @@ describe("GlideClusterClient", () => { let cluster: ValkeyCluster; let client: GlideClusterClient; beforeAll(async () => { + Logger.init("error"); + Logger.setLoggerConfig("error"); const clusterAddresses = parseCommandLineArgs()["cluster-endpoints"]; // Connect to cluster or create a new one based on the parsed addresses cluster = clusterAddresses @@ -245,7 +248,7 @@ describe("GlideClusterClient", () => { expect(await client.set(key, value)).toEqual("OK"); // Since DUMP gets binary results, we cannot use the default decoder (string) here, so we expected to get an error. await expect(client.customCommand(["DUMP", key])).rejects.toThrow( - "invalid utf-8 sequence of 1 bytes from index 9", + "invalid utf-8 sequence of 1 bytes from index", ); const dumpResult = await client.customCommand(["DUMP", key], { @@ -450,11 +453,15 @@ describe("GlideClusterClient", () => { ); } - for (const promise of promises) { - await expect(promise).rejects.toThrowError( - /Keys in request don't hash to the same slot/, - ); - } + await Promise.allSettled(promises).then((results) => { + results.forEach((result) => { + expect(result.status).toBe("rejected"); + + if (result.status === "rejected") { + expect(result.reason.message).toContain("CrossSlot"); + } + }); + }); client.close(); }, diff --git a/node/tests/ScanTest.test.ts b/node/tests/ScanTest.test.ts index e1ccb9bb06..016bc4038e 100644 --- a/node/tests/ScanTest.test.ts +++ b/node/tests/ScanTest.test.ts @@ -10,6 +10,7 @@ import { GlideClient, GlideClusterClient, GlideString, + Logger, ObjectType, ProtocolVersion, } from ".."; @@ -30,6 +31,8 @@ describe("Scan GlideClusterClient", () => { let cluster: ValkeyCluster; let client: GlideClusterClient; beforeAll(async () => { + Logger.init("error"); + Logger.setLoggerConfig("error"); const clusterAddresses = parseCommandLineArgs()["cluster-endpoints"]; // Connect to cluster or create a new one based on the parsed addresses cluster = clusterAddresses diff --git a/node/tests/SharedTests.ts b/node/tests/SharedTests.ts index 8ab62febab..b0d1abb452 100644 --- a/node/tests/SharedTests.ts +++ b/node/tests/SharedTests.ts @@ -38,6 +38,7 @@ import { InfoOptions, InsertPosition, ListDirection, + Logger, ProtocolVersion, RequestError, ScoreFilter, @@ -74,6 +75,8 @@ export function runBaseTests(config: { close: (testSucceeded: boolean) => void; timeout?: number; }) { + Logger.init("error"); + Logger.setLoggerConfig("error"); runCommonTests({ init: () => config.init(ProtocolVersion.RESP2), close: config.close, @@ -6434,7 +6437,7 @@ export function runBaseTests(config: { [key3], cluster.checkIfServerVersionLessThan("6.0.0") ? 1.0 - : 0.001, + : 0.01, ), ).toBeNull(); @@ -9254,11 +9257,20 @@ export function runBaseTests(config: { { reverse: true }, ), ).toEqual( - convertElementsAndScores({ - edge2: 236529.17986494553, - Palermo: 166274.15156960033, - Catania: 0.0, - }), + expect.arrayContaining([ + { + element: "edge2", + score: expect.closeTo(236529.17986494553, 0.0001), + }, + { + element: "Palermo", + score: expect.closeTo(166274.15156960033, 0.0001), + }, + { + element: "Catania", + score: expect.closeTo(0.0, 0.0001), + }, + ]), ); // test search by box, unit: feet, from member, with limited count 2, with hash