From 78090d1f151388343d77ef186106ff3c637e8bd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E7=BF=94?= Date: Tue, 21 Apr 2026 07:43:28 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=AD=A3=20Jest=20=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E4=B8=AD=E7=9A=84=E6=96=87=E4=BB=B6=E8=B7=AF=E5=BE=84?= =?UTF-8?q?=EF=BC=8C=E7=A7=BB=E9=99=A4=20next-auth=20mock?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/test/jest.config.js | 4 ++-- config/test/jest.setup.js | 33 +-------------------------------- 2 files changed, 3 insertions(+), 34 deletions(-) diff --git a/config/test/jest.config.js b/config/test/jest.config.js index 8087d69..7e060f9 100644 --- a/config/test/jest.config.js +++ b/config/test/jest.config.js @@ -18,7 +18,7 @@ module.exports = { }, }, coverageReporters: ['text', 'lcov', 'html', 'json'], - coverageDirectory: 'coverage', + coverageDirectory: '/coverage', moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'], moduleNameMapper: { '^@/(.*)$': '/src/$1', @@ -33,4 +33,4 @@ module.exports = { testTimeout: 10000, verbose: true, maxWorkers: '50%', -}; \ No newline at end of file +}; diff --git a/config/test/jest.setup.js b/config/test/jest.setup.js index 7c991a8..47ebba4 100644 --- a/config/test/jest.setup.js +++ b/config/test/jest.setup.js @@ -4,37 +4,6 @@ const { TextEncoder, TextDecoder } = require('util'); global.TextEncoder = TextEncoder; global.TextDecoder = TextDecoder; -jest.mock('next-auth', () => { - return { - __esModule: true, - default: jest.fn(() => ({ - handlers: { - authOptions: { - providers: [], - callbacks: {}, - pages: {}, - session: {}, - }, - }, - signIn: jest.fn(), - signOut: jest.fn(), - auth: jest.fn(), - })), - getServerSession: jest.fn(), - }; -}); - -jest.mock('next-auth/providers/credentials', () => - jest.fn(() => ({ - name: '邮箱密码', - credentials: { - email: { label: '邮箱', type: 'email' }, - password: { label: '密码', type: 'password' }, - }, - authorize: jest.fn(), - })) -); - jest.mock('nanoid', () => ({ nanoid: jest.fn(() => 'test-id-123'), })); @@ -191,4 +160,4 @@ global.Response = class Response { async text() { return String(this.body); } -}; \ No newline at end of file +};