Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/fair-showers-slide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@tapsioss/react-client-socket-manager": patch
"@tapsioss/client-socket-manager": patch
---

Increase test coverage.

7 changes: 7 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.changeset/**/*.md
!.changeset/**/README.md
**/CHANGELOG.md
**/dist
**/node_modules
pnpm-lock.*
LICENSE
3 changes: 1 addition & 2 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@ import { config, configs as tsLintConfigs } from "typescript-eslint";
export default config(
jsLint.configs.recommended,
...tsLintConfigs.recommendedTypeChecked,
/* eslint-disable @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access */
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
importPlugin.flatConfigs.recommended,
importPlugin.flatConfigs.typescript,
/* eslint-enable @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access */
prettierRecommendedConfig,
{
files: ["*.ts", "*.tsx"],
Expand Down
112 changes: 51 additions & 61 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,41 @@
"changesets:apply": "changeset version",
"changesets:status": "changeset status --since=main",
"release": "pnpm build && changeset publish --tag latest",
"build": "wireit",
"test": "vitest",
"test": "pnpm -r --parallel run test",
"build": "pnpm -r run build",
"format:check": "wireit",
"format:write": "wireit",
"lint": "wireit",
"dev": "pnpm --filter @repo/playground run dev",
"build:core": "wireit",
"build:react": "wireit"
"dev": "pnpm --filter @repo/playground run dev"
},
"wireit": {
"build": {
"dependencies": [
"build:core",
"build:react"
]
"format:check": {
"command": "prettier . --check --cache",
"files": [
"./.prettierrc",
"./.prettierignore",
"**/*.{js,jsx,ts,tsx,md,json,css}",
"!**/dist/**/*",
"!pnpm-lock.yaml"
],
"output": []
},
"format:write": {
"command": "prettier . --write --cache",
"files": [
"./.prettierrc",
"./.prettierignore",
"**/*.{js,jsx,ts,tsx,md,json,css}",
"!**/dist/**/*",
"!pnpm-lock.yaml"
],
"output": []
},
"lint": {
"dependencies": [
"lint:ts",
"lint:ecma"
"lint:ecma",
"format:check"
]
},
"lint:ts": {
Expand All @@ -47,77 +64,50 @@
"./eslint.config.js"
],
"output": []
},
"build:react": {
"command": "pnpm --filter @tapsioss/react-client-socket-manager run build",
"files": [
"./packages/react/tsconfig.json",
"./packages/react/tsconfig.*.json",
"./packages/react/src/**/*",
"!./packages/react/src/**/*.test.{ts,tsx}"
],
"output": [
"./packages/react/dist/**/*",
"./packages/react/dist/**/*.tsbuildinfo"
],
"dependencies": [
"build:core"
]
},
"build:core": {
"command": "pnpm --filter @tapsioss/client-socket-manager run build",
"files": [
"./packages/core/tsconfig.json",
"./packages/core/tsconfig.*.json",
"./packages/core/src/**/*",
"!./packages/react/src/**/*.test.{ts,tsx}"
],
"output": [
"./packages/core/dist/**/*",
"./packages/core/dist/**/*.tsbuildinfo"
]
}
},
"devDependencies": {
"@changesets/changelog-github": "^0.5.1",
"@changesets/cli": "^2.29.4",
"@eslint/js": "^9.28.0",
"@lit/react": "^1.0.7",
"@testing-library/dom": "^10.4.0",
"@testing-library/jest-dom": "^6.6.3",
"@changesets/cli": "^2.29.5",
"@eslint/js": "^9.33.0",
"@lit/react": "^1.0.8",
"@testing-library/dom": "^10.4.1",
"@testing-library/jest-dom": "^6.6.4",
"@testing-library/react": "^16.3.0",
"@testing-library/user-event": "^14.6.1",
"@types/eslint__js": "^8.42.3",
"@types/express": "^5.0.3",
"@types/node": "^20.19.0",
"@types/react": "^19.1.6",
"@types/react-dom": "^19.1.6",
"@vitejs/plugin-react": "^4.5.1",
"@types/node": "^20.19.10",
"@types/react": "^19.1.9",
"@types/react-dom": "^19.1.7",
"@vitejs/plugin-react": "^4.7.0",
"@vitest/coverage-v8": "^3.2.4",
"@vitest/eslint-plugin": "1.1.32-beta.3",
"eslint": "^9.28.0",
"eslint-config-prettier": "^9.1.0",
"eslint": "^9.33.0",
"eslint-config-prettier": "^9.1.2",
"eslint-import-resolver-typescript": "^3.10.1",
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-prettier": "^5.4.1",
"eslint-plugin-import": "^2.32.0",
"eslint-plugin-prettier": "^5.5.4",
"eslint-plugin-react": "^7.37.5",
"eslint-plugin-react-hooks": "^5.2.0",
"eslint-plugin-react-refresh": "^0.4.20",
"express": "^4.21.2",
"jsdom": "^26.1.0",
"npm-run-all": "^4.1.5",
"prettier": "^3.5.3",
"prettier-plugin-organize-imports": "^4.1.0",
"react": "^19.1.0",
"react-dom": "^19.1.0",
"prettier": "^3.6.2",
"prettier-plugin-organize-imports": "^4.2.0",
"react": "^19.1.1",
"react-dom": "^19.1.1",
"shx": "^0.3.4",
"socket.io": "^4.8.1",
"socket.io-client": "^4.8.1",
"tsx": "^4.19.4",
"typescript": "^5.8.3",
"typescript-eslint": "^8.33.1",
"tsup": "^8.5.0",
"tsx": "^4.20.3",
"typescript": "^5.9.2",
"typescript-eslint": "^8.39.0",
"vite-tsconfig-paths": "^5.1.4",
"vitest": "^3.2.2",
"vitest": "^3.2.4",
"wireit": "^0.14.12"
}
}
3 changes: 2 additions & 1 deletion packages/core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,8 @@ Show devtool in the browser programmatically.
##### Parameters

- `options`: Optional parameters.
- `zIndex`: Z-index of the devtool, overrides the previous z-index of the devtool.
- `zIndex`: Z-index of the devtool, overrides the previous z-index of the
devtool.

#### `hideDevtool`

Expand Down
37 changes: 26 additions & 11 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
"version": "0.6.0",
"type": "module",
"packageManager": "pnpm@9.15.0",
"main": "./dist/cjs/index.js",
"module": "./dist/esm/index.js",
"types": "./dist/cjs/index.d.ts",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"files": [
"./dist",
"./README.md",
"./LICENSE"
"README.md",
"LICENSE"
],
"exports": {
".": {
"require": "./dist/cjs/index.js",
"import": "./dist/esm/index.js",
"types": "./dist/cjs/index.d.ts"
"types": "./dist/index.d.ts",
"import": "./dist/index.js",
"require": "./dist/index.cjs"
}
},
"keywords": [
Expand All @@ -33,12 +33,27 @@
},
"scripts": {
"clear": "shx rm -rf dist",
"build:cjs": "tsc --project ./tsconfig.cjs.json",
"build:esm": "tsc --project ./tsconfig.esm.json",
"test": "vitest run",
"test:dev": "vitest",
"prebuild": "pnpm run clear",
"build": "run-p build:*",
"build": "wireit",
"release": "pnpm publish . --tag latest --access public --no-git-checks"
},
"wireit": {
"build": {
"command": "tsup",
"files": [
"./tsconfig.json",
"./tsup.config.ts",
"./src/**/*",
"!./src/**/*.test.{ts,tsx}"
],
"output": [
"./dist/**/*",
"./dist/**/*.tsbuildinfo"
]
}
},
"devDependencies": {
"@repo/test-helpers": "workspace:*"
},
Expand Down
35 changes: 35 additions & 0 deletions packages/core/src/ClientSocketManager.constructor-error.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { ClientSocketManager } from "./index.ts";

vi.mock("socket.io-client", () => ({
io: () => {
throw new Error("Connection failed");
},
}));

describe("ClientSocketManager: constructor error handling", () => {
let consoleErrorSpy: ReturnType<typeof vi.spyOn>;

beforeEach(() => {
consoleErrorSpy = vi.spyOn(console, "error").mockImplementation(() => {});
});

afterEach(() => {
consoleErrorSpy.mockRestore();
});

it("should handle constructor error and log to console", () => {
const socketManager = new ClientSocketManager("http://localhost:3000", {});

expect(consoleErrorSpy).toHaveBeenCalledWith(
"Failed to initialize socket connection",
expect.objectContaining({
uri: "http://localhost:3000",
path: "/socket.io",
err: expect.any(Error) as unknown,
}),
);

expect(socketManager).toBeDefined();
});
});
Loading