diff --git a/mcp-server/package.json b/mcp-server/package.json index 6ef6263..67dd7d5 100644 --- a/mcp-server/package.json +++ b/mcp-server/package.json @@ -23,9 +23,9 @@ }, "devDependencies": { "@eslint/js": "^9.39.1", - "@vitest/ui": "^3.2.4", + "@vitest/ui": "^4.0.14", "typescript": "^5.9.3", "typescript-eslint": "^8.48.0", - "vitest": "^3.2.4" + "vitest": "^4.0.14" } } diff --git a/mcp-server/src/integration/integration.test.ts b/mcp-server/src/integration/integration.test.ts index 087f6b1..c1beeec 100644 --- a/mcp-server/src/integration/integration.test.ts +++ b/mcp-server/src/integration/integration.test.ts @@ -19,28 +19,36 @@ vi.mock('../utils/http-client.js', () => ({ })) // Mock only the game classes from shared library +// In vitest v4, mocks used as constructors must use 'function' syntax vi.mock('@turn-based-mcp/shared', async (importOriginal) => { const actual = await importOriginal() as any return { ...actual, - TicTacToeGame: vi.fn(() => ({ - getValidMoves: vi.fn(() => [{ row: 0, col: 0 }]) - })), - RockPaperScissorsGame: vi.fn(() => ({})) + TicTacToeGame: vi.fn(function() { + return { + getValidMoves: vi.fn(() => [{ row: 0, col: 0 }]) + } + }), + RockPaperScissorsGame: vi.fn(function() { return {} }) } }) // Mock AI modules +// In vitest v4, mocks used as constructors must use 'function' syntax vi.mock('../ai/tic-tac-toe-ai.js', () => ({ - TicTacToeAI: vi.fn(() => ({ - makeMove: vi.fn(() => ({ row: 0, col: 0 })) - })) + TicTacToeAI: vi.fn(function() { + return { + makeMove: vi.fn(() => ({ row: 0, col: 0 })) + } + }) })) vi.mock('../ai/rock-paper-scissors-ai.js', () => ({ - RockPaperScissorsAI: vi.fn(() => ({ - makeChoice: vi.fn(() => 'rock') - })) + RockPaperScissorsAI: vi.fn(function() { + return { + makeChoice: vi.fn(() => 'rock') + } + }) })) describe('MCP Server Integration', () => { diff --git a/package-lock.json b/package-lock.json index 7036f96..1d6652f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,11 +17,11 @@ "@testing-library/jest-dom": "^6.9.1", "@testing-library/react": "^16.3.0", "@testing-library/user-event": "^14.6.1", - "@vitest/ui": "^3.2.4", + "@vitest/ui": "^4.0.14", "eslint": "^9.39.1", "typescript": "^5.9.3", "typescript-eslint": "^8.48.0", - "vitest": "^3.2.4" + "vitest": "^4.0.14" }, "engines": { "node": ">=18.0.0" @@ -36,10 +36,10 @@ }, "devDependencies": { "@eslint/js": "^9.39.1", - "@vitest/ui": "^3.2.4", + "@vitest/ui": "^4.0.14", "typescript": "^5.9.3", "typescript-eslint": "^8.48.0", - "vitest": "^3.2.4" + "vitest": "^4.0.14" } }, "node_modules/@adobe/css-tools": { @@ -2582,6 +2582,13 @@ "dev": true, "license": "MIT" }, + "node_modules/@standard-schema/spec": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@standard-schema/spec/-/spec-1.0.0.tgz", + "integrity": "sha512-m2bOd0f2RT9k8QJx1JN85cZYyH1RqFBdlwtkSlf4tBDYLCiiZnv1fIIwacK6cqwXavOydf0NPToMQgpKq+dVlA==", + "dev": true, + "license": "MIT" + }, "node_modules/@swc/helpers": { "version": "0.5.15", "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.15.tgz", @@ -3854,77 +3861,41 @@ } } }, - "node_modules/@vitest/coverage-v8/node_modules/@vitest/pretty-format": { - "version": "4.0.14", - "resolved": "https://registry.npmjs.org/@vitest/pretty-format/-/pretty-format-4.0.14.tgz", - "integrity": "sha512-SOYPgujB6TITcJxgd3wmsLl+wZv+fy3av2PpiPpsWPZ6J1ySUYfScfpIt2Yv56ShJXR2MOA6q2KjKHN4EpdyRQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "tinyrainbow": "^3.0.3" - }, - "funding": { - "url": "https://opencollective.com/vitest" - } - }, - "node_modules/@vitest/coverage-v8/node_modules/@vitest/utils": { - "version": "4.0.14", - "resolved": "https://registry.npmjs.org/@vitest/utils/-/utils-4.0.14.tgz", - "integrity": "sha512-hLqXZKAWNg8pI+SQXyXxWCTOpA3MvsqcbVeNgSi8x/CSN2wi26dSzn1wrOhmCmFjEvN9p8/kLFRHa6PI8jHazw==", - "dev": true, - "license": "MIT", - "dependencies": { - "@vitest/pretty-format": "4.0.14", - "tinyrainbow": "^3.0.3" - }, - "funding": { - "url": "https://opencollective.com/vitest" - } - }, - "node_modules/@vitest/coverage-v8/node_modules/tinyrainbow": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/tinyrainbow/-/tinyrainbow-3.0.3.tgz", - "integrity": "sha512-PSkbLUoxOFRzJYjjxHJt9xro7D+iilgMX/C9lawzVuYiIdcihh9DXmVibBe8lmcFrRi/VzlPjBxbN7rH24q8/Q==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=14.0.0" - } - }, "node_modules/@vitest/expect": { - "version": "3.2.4", - "resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-3.2.4.tgz", - "integrity": "sha512-Io0yyORnB6sikFlt8QW5K7slY4OjqNX9jmJQ02QDda8lyM6B5oNgVWoSoKPac8/kgnCUzuHQKrSLtu/uOqqrig==", + "version": "4.0.14", + "resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-4.0.14.tgz", + "integrity": "sha512-RHk63V3zvRiYOWAV0rGEBRO820ce17hz7cI2kDmEdfQsBjT2luEKB5tCOc91u1oSQoUOZkSv3ZyzkdkSLD7lKw==", "dev": true, "license": "MIT", "dependencies": { + "@standard-schema/spec": "^1.0.0", "@types/chai": "^5.2.2", - "@vitest/spy": "3.2.4", - "@vitest/utils": "3.2.4", - "chai": "^5.2.0", - "tinyrainbow": "^2.0.0" + "@vitest/spy": "4.0.14", + "@vitest/utils": "4.0.14", + "chai": "^6.2.1", + "tinyrainbow": "^3.0.3" }, "funding": { "url": "https://opencollective.com/vitest" } }, "node_modules/@vitest/mocker": { - "version": "3.2.4", - "resolved": "https://registry.npmjs.org/@vitest/mocker/-/mocker-3.2.4.tgz", - "integrity": "sha512-46ryTE9RZO/rfDd7pEqFl7etuyzekzEhUbTW3BvmeO/BcCMEgq59BKhek3dXDWgAj4oMK6OZi+vRr1wPW6qjEQ==", + "version": "4.0.14", + "resolved": "https://registry.npmjs.org/@vitest/mocker/-/mocker-4.0.14.tgz", + "integrity": "sha512-RzS5NujlCzeRPF1MK7MXLiEFpkIXeMdQ+rN3Kk3tDI9j0mtbr7Nmuq67tpkOJQpgyClbOltCXMjLZicJHsH5Cg==", "dev": true, "license": "MIT", "dependencies": { - "@vitest/spy": "3.2.4", + "@vitest/spy": "4.0.14", "estree-walker": "^3.0.3", - "magic-string": "^0.30.17" + "magic-string": "^0.30.21" }, "funding": { "url": "https://opencollective.com/vitest" }, "peerDependencies": { "msw": "^2.4.9", - "vite": "^5.0.0 || ^6.0.0 || ^7.0.0-0" + "vite": "^6.0.0 || ^7.0.0-0" }, "peerDependenciesMeta": { "msw": { @@ -3936,42 +3907,41 @@ } }, "node_modules/@vitest/pretty-format": { - "version": "3.2.4", - "resolved": "https://registry.npmjs.org/@vitest/pretty-format/-/pretty-format-3.2.4.tgz", - "integrity": "sha512-IVNZik8IVRJRTr9fxlitMKeJeXFFFN0JaB9PHPGQ8NKQbGpfjlTx9zO4RefN8gp7eqjNy8nyK3NZmBzOPeIxtA==", + "version": "4.0.14", + "resolved": "https://registry.npmjs.org/@vitest/pretty-format/-/pretty-format-4.0.14.tgz", + "integrity": "sha512-SOYPgujB6TITcJxgd3wmsLl+wZv+fy3av2PpiPpsWPZ6J1ySUYfScfpIt2Yv56ShJXR2MOA6q2KjKHN4EpdyRQ==", "dev": true, "license": "MIT", "dependencies": { - "tinyrainbow": "^2.0.0" + "tinyrainbow": "^3.0.3" }, "funding": { "url": "https://opencollective.com/vitest" } }, "node_modules/@vitest/runner": { - "version": "3.2.4", - "resolved": "https://registry.npmjs.org/@vitest/runner/-/runner-3.2.4.tgz", - "integrity": "sha512-oukfKT9Mk41LreEW09vt45f8wx7DordoWUZMYdY/cyAk7w5TWkTRCNZYF7sX7n2wB7jyGAl74OxgwhPgKaqDMQ==", + "version": "4.0.14", + "resolved": "https://registry.npmjs.org/@vitest/runner/-/runner-4.0.14.tgz", + "integrity": "sha512-BsAIk3FAqxICqREbX8SetIteT8PiaUL/tgJjmhxJhCsigmzzH8xeadtp7LRnTpCVzvf0ib9BgAfKJHuhNllKLw==", "dev": true, "license": "MIT", "dependencies": { - "@vitest/utils": "3.2.4", - "pathe": "^2.0.3", - "strip-literal": "^3.0.0" + "@vitest/utils": "4.0.14", + "pathe": "^2.0.3" }, "funding": { "url": "https://opencollective.com/vitest" } }, "node_modules/@vitest/snapshot": { - "version": "3.2.4", - "resolved": "https://registry.npmjs.org/@vitest/snapshot/-/snapshot-3.2.4.tgz", - "integrity": "sha512-dEYtS7qQP2CjU27QBC5oUOxLE/v5eLkGqPE0ZKEIDGMs4vKWe7IjgLOeauHsR0D5YuuycGRO5oSRXnwnmA78fQ==", + "version": "4.0.14", + "resolved": "https://registry.npmjs.org/@vitest/snapshot/-/snapshot-4.0.14.tgz", + "integrity": "sha512-aQVBfT1PMzDSA16Y3Fp45a0q8nKexx6N5Amw3MX55BeTeZpoC08fGqEZqVmPcqN0ueZsuUQ9rriPMhZ3Mu19Ag==", "dev": true, "license": "MIT", "dependencies": { - "@vitest/pretty-format": "3.2.4", - "magic-string": "^0.30.17", + "@vitest/pretty-format": "4.0.14", + "magic-string": "^0.30.21", "pathe": "^2.0.3" }, "funding": { @@ -3979,50 +3949,46 @@ } }, "node_modules/@vitest/spy": { - "version": "3.2.4", - "resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-3.2.4.tgz", - "integrity": "sha512-vAfasCOe6AIK70iP5UD11Ac4siNUNJ9i/9PZ3NKx07sG6sUxeag1LWdNrMWeKKYBLlzuK+Gn65Yd5nyL6ds+nw==", + "version": "4.0.14", + "resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-4.0.14.tgz", + "integrity": "sha512-JmAZT1UtZooO0tpY3GRyiC/8W7dCs05UOq9rfsUUgEZEdq+DuHLmWhPsrTt0TiW7WYeL/hXpaE07AZ2RCk44hg==", "dev": true, "license": "MIT", - "dependencies": { - "tinyspy": "^4.0.3" - }, "funding": { "url": "https://opencollective.com/vitest" } }, "node_modules/@vitest/ui": { - "version": "3.2.4", - "resolved": "https://registry.npmjs.org/@vitest/ui/-/ui-3.2.4.tgz", - "integrity": "sha512-hGISOaP18plkzbWEcP/QvtRW1xDXF2+96HbEX6byqQhAUbiS5oH6/9JwW+QsQCIYON2bI6QZBF+2PvOmrRZ9wA==", + "version": "4.0.14", + "resolved": "https://registry.npmjs.org/@vitest/ui/-/ui-4.0.14.tgz", + "integrity": "sha512-fvDz8o7SQpFLoSBo6Cudv+fE85/fPCkwTnLAN85M+Jv7k59w2mSIjT9Q5px7XwGrmYqqKBEYxh/09IBGd1E7AQ==", "dev": true, "license": "MIT", "dependencies": { - "@vitest/utils": "3.2.4", + "@vitest/utils": "4.0.14", "fflate": "^0.8.2", "flatted": "^3.3.3", "pathe": "^2.0.3", - "sirv": "^3.0.1", - "tinyglobby": "^0.2.14", - "tinyrainbow": "^2.0.0" + "sirv": "^3.0.2", + "tinyglobby": "^0.2.15", + "tinyrainbow": "^3.0.3" }, "funding": { "url": "https://opencollective.com/vitest" }, "peerDependencies": { - "vitest": "3.2.4" + "vitest": "4.0.14" } }, "node_modules/@vitest/utils": { - "version": "3.2.4", - "resolved": "https://registry.npmjs.org/@vitest/utils/-/utils-3.2.4.tgz", - "integrity": "sha512-fB2V0JFrQSMsCo9HiSq3Ezpdv4iYaXRG1Sx8edX3MwxfyNn83mKiGzOcH+Fkxt4MHxr3y42fQi1oeAInqgX2QA==", + "version": "4.0.14", + "resolved": "https://registry.npmjs.org/@vitest/utils/-/utils-4.0.14.tgz", + "integrity": "sha512-hLqXZKAWNg8pI+SQXyXxWCTOpA3MvsqcbVeNgSi8x/CSN2wi26dSzn1wrOhmCmFjEvN9p8/kLFRHa6PI8jHazw==", "dev": true, "license": "MIT", "dependencies": { - "@vitest/pretty-format": "3.2.4", - "loupe": "^3.1.4", - "tinyrainbow": "^2.0.0" + "@vitest/pretty-format": "4.0.14", + "tinyrainbow": "^3.0.3" }, "funding": { "url": "https://opencollective.com/vitest" @@ -4654,16 +4620,6 @@ "node": ">= 0.8" } }, - "node_modules/cac": { - "version": "6.7.14", - "resolved": "https://registry.npmjs.org/cac/-/cac-6.7.14.tgz", - "integrity": "sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=8" - } - }, "node_modules/cacache": { "version": "15.3.0", "resolved": "https://registry.npmjs.org/cacache/-/cacache-15.3.0.tgz", @@ -4828,18 +4784,11 @@ } }, "node_modules/chai": { - "version": "5.3.3", - "resolved": "https://registry.npmjs.org/chai/-/chai-5.3.3.tgz", - "integrity": "sha512-4zNhdJD/iOjSH0A05ea+Ke6MU5mmpQcbQsSOkgdaUMJ9zTlDTD/GYlwohmIE2u0gaxHYiVHEn1Fw9mZ/ktJWgw==", + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/chai/-/chai-6.2.1.tgz", + "integrity": "sha512-p4Z49OGG5W/WBCPSS/dH3jQ73kD6tiMmUM+bckNK6Jr5JHMG3k9bg/BvKR8lKmtVBKmOiuVaV2ws8s9oSbwysg==", "dev": true, "license": "MIT", - "dependencies": { - "assertion-error": "^2.0.1", - "check-error": "^2.1.1", - "deep-eql": "^5.0.1", - "loupe": "^3.1.0", - "pathval": "^2.0.0" - }, "engines": { "node": ">=18" } @@ -4861,16 +4810,6 @@ "url": "https://github.com/chalk/chalk?sponsor=1" } }, - "node_modules/check-error": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/check-error/-/check-error-2.1.1.tgz", - "integrity": "sha512-OAlb+T7V4Op9OwdkjmguYRqncdlx5JiofwOAUkmTF+jNdHwzTaTs4sRAGpzLF3oOz5xAyDGrPgeIDFQmDOTiJw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 16" - } - }, "node_modules/chownr": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/chownr/-/chownr-2.0.0.tgz", @@ -5198,16 +5137,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/deep-eql": { - "version": "5.0.2", - "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-5.0.2.tgz", - "integrity": "sha512-h5k/5U50IJJFpzfL6nO9jaaumfjO/f2NjK/oYB2Djzm4p9L+3T9qWpZqZ2hAbLPuuYq9wrU08WQyBTL5GbPk5Q==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6" - } - }, "node_modules/deep-extend": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.6.0.tgz", @@ -8411,13 +8340,6 @@ "loose-envify": "cli.js" } }, - "node_modules/loupe": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/loupe/-/loupe-3.2.1.tgz", - "integrity": "sha512-CdzqowRJCeLU72bHvWqwRBBlLcMEtIvGrlvef74kMnV2AolS9Y8xUv1I0U/MNAWMhBlKIoyuEgoJ0t/bbwHbLQ==", - "dev": true, - "license": "MIT" - }, "node_modules/lru-cache": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", @@ -9430,16 +9352,6 @@ "dev": true, "license": "MIT" }, - "node_modules/pathval": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/pathval/-/pathval-2.0.1.tgz", - "integrity": "sha512-//nshmD55c46FuFw26xV/xFAaB5HF9Xdap7HJBBnrKdAd6/GxDBaNA1870O79+9ueg61cZLSVc+OaFlfmObYVQ==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 14.16" - } - }, "node_modules/picocolors": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", @@ -10905,26 +10817,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/strip-literal": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/strip-literal/-/strip-literal-3.1.0.tgz", - "integrity": "sha512-8r3mkIM/2+PpjHoOtiAW8Rg3jJLHaV7xPwG+YRGrv6FP0wwk/toTpATxWYOW0BKdWwl82VT2tFYi5DlROa0Mxg==", - "dev": true, - "license": "MIT", - "dependencies": { - "js-tokens": "^9.0.1" - }, - "funding": { - "url": "https://github.com/sponsors/antfu" - } - }, - "node_modules/strip-literal/node_modules/js-tokens": { - "version": "9.0.1", - "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-9.0.1.tgz", - "integrity": "sha512-mxa9E9ITFOt0ban3j6L5MpjwegGz6lBQmM1IJkWeBZGcMxto50+eWdjC/52xDbS2vy0k7vIMK0Fe2wfL9OQSpQ==", - "dev": true, - "license": "MIT" - }, "node_modules/styled-jsx": { "version": "5.1.6", "resolved": "https://registry.npmjs.org/styled-jsx/-/styled-jsx-5.1.6.tgz", @@ -11156,30 +11048,10 @@ "url": "https://github.com/sponsors/SuperchupuDev" } }, - "node_modules/tinypool": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/tinypool/-/tinypool-1.1.1.tgz", - "integrity": "sha512-Zba82s87IFq9A9XmjiX5uZA/ARWDrB03OHlq+Vw1fSdt0I+4/Kutwy8BP4Y/y/aORMo61FQ0vIb5j44vSo5Pkg==", - "dev": true, - "license": "MIT", - "engines": { - "node": "^18.0.0 || >=20.0.0" - } - }, "node_modules/tinyrainbow": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/tinyrainbow/-/tinyrainbow-2.0.0.tgz", - "integrity": "sha512-op4nsTR47R6p0vMUUoYl/a+ljLFVtlfaXkLQmqfLR1qHma1h/ysYk4hEXZ880bf2CYgTskvTa/e196Vd5dDQXw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=14.0.0" - } - }, - "node_modules/tinyspy": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/tinyspy/-/tinyspy-4.0.4.tgz", - "integrity": "sha512-azl+t0z7pw/z958Gy9svOTuzqIk6xq+NSheJzn5MMWtWTFywIacg2wUlzKFGtt3cthx0r2SxMK0yzJOR0IES7Q==", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/tinyrainbow/-/tinyrainbow-3.0.3.tgz", + "integrity": "sha512-PSkbLUoxOFRzJYjjxHJt9xro7D+iilgMX/C9lawzVuYiIdcihh9DXmVibBe8lmcFrRi/VzlPjBxbN7rH24q8/Q==", "dev": true, "license": "MIT", "engines": { @@ -11780,75 +11652,51 @@ } } }, - "node_modules/vite-node": { - "version": "3.2.4", - "resolved": "https://registry.npmjs.org/vite-node/-/vite-node-3.2.4.tgz", - "integrity": "sha512-EbKSKh+bh1E1IFxeO0pg1n4dvoOTt0UDiXMd/qn++r98+jPO1xtJilvXldeuQ8giIB5IkpjCgMleHMNEsGH6pg==", - "dev": true, - "license": "MIT", - "dependencies": { - "cac": "^6.7.14", - "debug": "^4.4.1", - "es-module-lexer": "^1.7.0", - "pathe": "^2.0.3", - "vite": "^5.0.0 || ^6.0.0 || ^7.0.0-0" - }, - "bin": { - "vite-node": "vite-node.mjs" - }, - "engines": { - "node": "^18.0.0 || ^20.0.0 || >=22.0.0" - }, - "funding": { - "url": "https://opencollective.com/vitest" - } - }, "node_modules/vitest": { - "version": "3.2.4", - "resolved": "https://registry.npmjs.org/vitest/-/vitest-3.2.4.tgz", - "integrity": "sha512-LUCP5ev3GURDysTWiP47wRRUpLKMOfPh+yKTx3kVIEiu5KOMeqzpnYNsKyOoVrULivR8tLcks4+lga33Whn90A==", + "version": "4.0.14", + "resolved": "https://registry.npmjs.org/vitest/-/vitest-4.0.14.tgz", + "integrity": "sha512-d9B2J9Cm9dN9+6nxMnnNJKJCtcyKfnHj15N6YNJfaFHRLua/d3sRKU9RuKmO9mB0XdFtUizlxfz/VPbd3OxGhw==", "dev": true, "license": "MIT", "dependencies": { - "@types/chai": "^5.2.2", - "@vitest/expect": "3.2.4", - "@vitest/mocker": "3.2.4", - "@vitest/pretty-format": "^3.2.4", - "@vitest/runner": "3.2.4", - "@vitest/snapshot": "3.2.4", - "@vitest/spy": "3.2.4", - "@vitest/utils": "3.2.4", - "chai": "^5.2.0", - "debug": "^4.4.1", - "expect-type": "^1.2.1", - "magic-string": "^0.30.17", + "@vitest/expect": "4.0.14", + "@vitest/mocker": "4.0.14", + "@vitest/pretty-format": "4.0.14", + "@vitest/runner": "4.0.14", + "@vitest/snapshot": "4.0.14", + "@vitest/spy": "4.0.14", + "@vitest/utils": "4.0.14", + "es-module-lexer": "^1.7.0", + "expect-type": "^1.2.2", + "magic-string": "^0.30.21", + "obug": "^2.1.1", "pathe": "^2.0.3", - "picomatch": "^4.0.2", - "std-env": "^3.9.0", + "picomatch": "^4.0.3", + "std-env": "^3.10.0", "tinybench": "^2.9.0", "tinyexec": "^0.3.2", - "tinyglobby": "^0.2.14", - "tinypool": "^1.1.1", - "tinyrainbow": "^2.0.0", - "vite": "^5.0.0 || ^6.0.0 || ^7.0.0-0", - "vite-node": "3.2.4", + "tinyglobby": "^0.2.15", + "tinyrainbow": "^3.0.3", + "vite": "^6.0.0 || ^7.0.0", "why-is-node-running": "^2.3.0" }, "bin": { "vitest": "vitest.mjs" }, "engines": { - "node": "^18.0.0 || ^20.0.0 || >=22.0.0" + "node": "^20.0.0 || ^22.0.0 || >=24.0.0" }, "funding": { "url": "https://opencollective.com/vitest" }, "peerDependencies": { "@edge-runtime/vm": "*", - "@types/debug": "^4.1.12", - "@types/node": "^18.0.0 || ^20.0.0 || >=22.0.0", - "@vitest/browser": "3.2.4", - "@vitest/ui": "3.2.4", + "@opentelemetry/api": "^1.9.0", + "@types/node": "^20.0.0 || ^22.0.0 || >=24.0.0", + "@vitest/browser-playwright": "4.0.14", + "@vitest/browser-preview": "4.0.14", + "@vitest/browser-webdriverio": "4.0.14", + "@vitest/ui": "4.0.14", "happy-dom": "*", "jsdom": "*" }, @@ -11856,13 +11704,19 @@ "@edge-runtime/vm": { "optional": true }, - "@types/debug": { + "@opentelemetry/api": { "optional": true }, "@types/node": { "optional": true }, - "@vitest/browser": { + "@vitest/browser-playwright": { + "optional": true + }, + "@vitest/browser-preview": { + "optional": true + }, + "@vitest/browser-webdriverio": { "optional": true }, "@vitest/ui": { @@ -12224,12 +12078,12 @@ "@jest/types": "30.2.0", "@types/jest": "^30.0.0", "@vitest/coverage-v8": "^4.0.14", - "@vitest/ui": "^3.2.4", + "@vitest/ui": "^4.0.14", "eslint": "^9.39.1", "fix-esm-import-path": "^1.10.3", "typescript": "^5.9.3", "typescript-eslint": "^8.48.0", - "vitest": "^3.2.4" + "vitest": "^4.0.14" } }, "web": { @@ -12257,7 +12111,7 @@ "@types/react": "^19.2.7", "@types/react-dom": "^19.2.3", "@vitejs/plugin-react": "^5.1.1", - "@vitest/ui": "^3.2.4", + "@vitest/ui": "^4.0.14", "eslint": "^9.39.1", "eslint-config-next": "^16.0.5", "eslint-plugin-react": "^7.37.5", @@ -12268,7 +12122,7 @@ "typescript": "^5.9.3", "typescript-eslint": "^8.48.0", "undici": "^7.16.0", - "vitest": "^3.2.4" + "vitest": "^4.0.14" } } } diff --git a/package.json b/package.json index 3f2d391..fcbaf3a 100644 --- a/package.json +++ b/package.json @@ -29,11 +29,11 @@ "@testing-library/jest-dom": "^6.9.1", "@testing-library/react": "^16.3.0", "@testing-library/user-event": "^14.6.1", - "@vitest/ui": "^3.2.4", + "@vitest/ui": "^4.0.14", "eslint": "^9.39.1", "typescript": "^5.9.3", "typescript-eslint": "^8.48.0", - "vitest": "^3.2.4" + "vitest": "^4.0.14" }, "engines": { "node": ">=18.0.0" diff --git a/shared/package.json b/shared/package.json index bc86754..bf91b13 100644 --- a/shared/package.json +++ b/shared/package.json @@ -36,12 +36,12 @@ "@jest/types": "30.2.0", "@types/jest": "^30.0.0", "@vitest/coverage-v8": "^4.0.14", - "@vitest/ui": "^3.2.4", + "@vitest/ui": "^4.0.14", "eslint": "^9.39.1", "fix-esm-import-path": "^1.10.3", "typescript": "^5.9.3", "typescript-eslint": "^8.48.0", - "vitest": "^3.2.4" + "vitest": "^4.0.14" }, "dependencies": { "sqlite3": "^5.1.7" diff --git a/shared/src/storage/sqlite-storage.test.ts b/shared/src/storage/sqlite-storage.test.ts index 2c5cdd4..9dc70f6 100644 --- a/shared/src/storage/sqlite-storage.test.ts +++ b/shared/src/storage/sqlite-storage.test.ts @@ -2,28 +2,31 @@ import { vi } from 'vitest' import * as sqliteStorage from './sqlite-storage'; // Mock sqlite3 to prevent actual database operations +// In vitest v4, mocks used as constructors must use 'function' or 'class' syntax vi.mock('sqlite3', () => ({ default: { - Database: vi.fn().mockImplementation(() => ({ - run: vi.fn(function(sql, params, callback) { - if (callback) { - // Mock the 'this' context with lastID and changes - callback.call({ lastID: 1, changes: 1 }); - } - }), - get: vi.fn((sql, params, callback) => { - if (callback) callback(null, null); - }), - all: vi.fn((sql, params, callback) => { - if (callback) callback(null, []); - }), - close: vi.fn((callback) => { - if (callback) callback(); - }), - serialize: vi.fn((fn) => { - if (fn) fn(); - }) - })) + Database: vi.fn(function() { + return { + run: vi.fn(function(sql: string, params: unknown, callback?: (this: { lastID: number; changes: number }) => void) { + if (callback) { + // Mock the 'this' context with lastID and changes + callback.call({ lastID: 1, changes: 1 }); + } + }), + get: vi.fn((sql: string, params: unknown, callback?: (err: Error | null, row: unknown) => void) => { + if (callback) callback(null, null); + }), + all: vi.fn((sql: string, params: unknown, callback?: (err: Error | null, rows: unknown[]) => void) => { + if (callback) callback(null, []); + }), + close: vi.fn((callback?: () => void) => { + if (callback) callback(); + }), + serialize: vi.fn((fn?: () => void) => { + if (fn) fn(); + }) + }; + }) } })); diff --git a/web/package.json b/web/package.json index 06980ae..c9f57ab 100644 --- a/web/package.json +++ b/web/package.json @@ -38,7 +38,7 @@ "@types/react": "^19.2.7", "@types/react-dom": "^19.2.3", "@vitejs/plugin-react": "^5.1.1", - "@vitest/ui": "^3.2.4", + "@vitest/ui": "^4.0.14", "eslint": "^9.39.1", "eslint-config-next": "^16.0.5", "eslint-plugin-react": "^7.37.5", @@ -49,6 +49,6 @@ "typescript": "^5.9.3", "typescript-eslint": "^8.48.0", "undici": "^7.16.0", - "vitest": "^3.2.4" + "vitest": "^4.0.14" } } diff --git a/web/src/app/api/games/rock-paper-scissors/[id]/move/route.test.ts b/web/src/app/api/games/rock-paper-scissors/[id]/move/route.test.ts index 90819a8..9327c52 100644 --- a/web/src/app/api/games/rock-paper-scissors/[id]/move/route.test.ts +++ b/web/src/app/api/games/rock-paper-scissors/[id]/move/route.test.ts @@ -3,6 +3,7 @@ import { NextRequest } from 'next/server'; import type { GameSession, RPSGameState, RPSMove } from '@turn-based-mcp/shared'; // Mock dependencies BEFORE importing the route - use factory functions for proper setup +// In vitest v4, mocks used as constructors must use 'function' syntax vi.mock('@turn-based-mcp/shared', () => { const mockGame = { getInitialState: vi.fn(), @@ -14,7 +15,7 @@ vi.mock('@turn-based-mcp/shared', () => { return { ...vi.importActual('@turn-based-mcp/shared'), - RockPaperScissorsGame: vi.fn(() => mockGame), + RockPaperScissorsGame: vi.fn(function() { return mockGame; }), __mockGameInstance: mockGame }; }); diff --git a/web/src/app/api/games/rock-paper-scissors/route.test.ts b/web/src/app/api/games/rock-paper-scissors/route.test.ts index c0a1151..3548772 100644 --- a/web/src/app/api/games/rock-paper-scissors/route.test.ts +++ b/web/src/app/api/games/rock-paper-scissors/route.test.ts @@ -13,9 +13,10 @@ const mockGame = vi.hoisted(() => ({ })); // Mock dependencies BEFORE importing the route +// In vitest v4, mocks used as constructors must use 'function' syntax vi.mock('@turn-based-mcp/shared', () => ({ ...vi.importActual('@turn-based-mcp/shared'), - RockPaperScissorsGame: vi.fn().mockImplementation(() => mockGame) + RockPaperScissorsGame: vi.fn(function() { return mockGame; }) })); vi.mock('../../../../lib/game-storage', () => ({ diff --git a/web/src/app/api/games/tic-tac-toe/[id]/move/route.test.ts b/web/src/app/api/games/tic-tac-toe/[id]/move/route.test.ts index b3e0327..01b8df3 100644 --- a/web/src/app/api/games/tic-tac-toe/[id]/move/route.test.ts +++ b/web/src/app/api/games/tic-tac-toe/[id]/move/route.test.ts @@ -3,6 +3,7 @@ import { NextRequest } from 'next/server'; import type { GameSession, TicTacToeGameState, TicTacToeMove } from '@turn-based-mcp/shared'; // Mock dependencies BEFORE importing the route - use factory functions for proper setup +// In vitest v4, mocks used as constructors must use 'function' syntax vi.mock('@turn-based-mcp/shared', () => { const mockGame = { getInitialState: vi.fn(), @@ -14,7 +15,7 @@ vi.mock('@turn-based-mcp/shared', () => { return { ...vi.importActual('@turn-based-mcp/shared'), - TicTacToeGame: vi.fn(() => mockGame), + TicTacToeGame: vi.fn(function() { return mockGame; }), getTicTacToeGame: vi.fn(), setTicTacToeGame: vi.fn(), __mockGameInstance: mockGame diff --git a/web/src/app/api/games/tic-tac-toe/route.test.ts b/web/src/app/api/games/tic-tac-toe/route.test.ts index b28bd43..ab073bf 100644 --- a/web/src/app/api/games/tic-tac-toe/route.test.ts +++ b/web/src/app/api/games/tic-tac-toe/route.test.ts @@ -13,9 +13,10 @@ const mockGame = vi.hoisted(() => ({ })); // Mock dependencies BEFORE importing the route +// In vitest v4, mocks used as constructors must use 'function' syntax vi.mock('@turn-based-mcp/shared', () => ({ ...vi.importActual('@turn-based-mcp/shared'), - TicTacToeGame: vi.fn().mockImplementation(() => mockGame) + TicTacToeGame: vi.fn(function() { return mockGame; }) })); vi.mock('../../../../lib/game-storage', () => ({