Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
felipecsl committed Feb 21, 2025
1 parent a2166ae commit 0007605
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 7 deletions.
10 changes: 6 additions & 4 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export const presets = [
["@babel/preset-env", { targets: { node: "current" } }],
"@babel/preset-typescript",
];
export default {
presets: [
["@babel/preset-env", { targets: { node: "current" }, modules: "auto" }],
"@babel/preset-typescript",
],
};
11 changes: 11 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export default {
extensionsToTreatAsEsm: [".ts", ".tsx"],
moduleNameMapper: {
"^(\\.{1,2}/.*)\\.js$": "$1",
},
transform: {
"^.+\\.(t|j)sx?$": "babel-jest",
},
transformIgnorePatterns: ["/node_modules/(?!(lodash-es|obgen)/)"],
testEnvironment: "node",
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"bundle": "esbuild dist/client/tdaWsJsonClient.js --bundle --outfile=dist/app.bundle.js --minify --sourcemap --target=es2020",
"check_prettier": "prettier --check .",
"lint": "eslint .",
"test": "yarn run jest",
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
"ci": "yarn check_prettier && yarn build && yarn lint && yarn test"
},
"dependencies": {
Expand Down
5 changes: 3 additions & 2 deletions src/test/client/wsJsonClient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
} from "../../client/tdaWsJsonTypes";

const accessToken = "something-secret";
const refreshToken = "something-secret-refresh";
const fakeConnectionResponse = {
session: "17a7_7115011e1b4a8c9c",
build: "27.2323.3-B0",
Expand Down Expand Up @@ -116,7 +117,7 @@ describe("wsJsonClientTest", () => {
try {
await server.connected;
// explicitly do not await for this promise so that we can send the server replies below
client.authenticate(accessToken);
client.authenticateWithAccessToken({ accessToken, refreshToken });
server.send(fakeConnectionResponse);
server.send(fakeLoginResponse);
await expect(server).toReceiveMessage(CONNECTION_REQUEST_MESSAGE);
Expand Down Expand Up @@ -153,7 +154,7 @@ describe("wsJsonClientTest", () => {
try {
await server.connected;
// explicitly do not await for this promise so that we can send the server replies below
client.authenticate(accessToken);
client.authenticateWithAccessToken({ accessToken, refreshToken });
server.send(fakeConnectionResponse);
server.send(fakeLoginResponse);
await expect(server).toReceiveMessage(CONNECTION_REQUEST_MESSAGE);
Expand Down

0 comments on commit 0007605

Please sign in to comment.