fix: 修正 Jest 配置中的文件路径,移除 next-auth mock

This commit is contained in:
张翔
2026-04-21 07:43:28 +08:00
parent a88466965b
commit 78090d1f15
2 changed files with 3 additions and 34 deletions
+1 -1
View File
@@ -18,7 +18,7 @@ module.exports = {
},
},
coverageReporters: ['text', 'lcov', 'html', 'json'],
coverageDirectory: 'coverage',
coverageDirectory: '<rootDir>/coverage',
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
moduleNameMapper: {
'^@/(.*)$': '<rootDir>/src/$1',
-31
View File
@@ -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'),
}));