- Adds knex.js to manage database schema changes systematically. - Creates an initial migration file based on `hyungi_schema_v2.sql` to represent the current database state. - Adds npm scripts (`db:migrate`, `db:rollback`, etc.) for easy execution of migration tasks. - Archives legacy SQL files and old migration scripts into the `db_archive/` directory to prevent confusion and clean up the project structure.
68 lines
1.4 KiB
JavaScript
68 lines
1.4 KiB
JavaScript
/**
|
|
* Jest 전역 테스트 설정
|
|
*
|
|
* 모든 테스트 실행 전 자동으로 로드됩니다
|
|
*/
|
|
|
|
// 환경 변수 설정 (테스트 환경)
|
|
process.env.NODE_ENV = 'test';
|
|
process.env.LOG_LEVEL = 'error'; // 테스트 시 로그 최소화
|
|
|
|
// 타임존 설정
|
|
process.env.TZ = 'Asia/Seoul';
|
|
|
|
// 전역 타임아웃 확장 (필요 시)
|
|
jest.setTimeout(10000);
|
|
|
|
// 콘솔 출력 모킹 (선택사항 - 테스트 출력을 깔끔하게)
|
|
// global.console = {
|
|
// ...console,
|
|
// log: jest.fn(),
|
|
// debug: jest.fn(),
|
|
// info: jest.fn(),
|
|
// warn: jest.fn(),
|
|
// error: jest.fn(),
|
|
// };
|
|
|
|
// 모든 테스트 실행 전
|
|
beforeAll(() => {
|
|
// 전역 설정
|
|
});
|
|
|
|
// 각 테스트 파일 실행 전
|
|
beforeEach(() => {
|
|
// 각 테스트 전 초기화
|
|
});
|
|
|
|
// 각 테스트 파일 실행 후
|
|
afterEach(() => {
|
|
// 모킹 정리
|
|
jest.clearAllMocks();
|
|
});
|
|
|
|
// 모든 테스트 실행 후
|
|
afterAll(() => {
|
|
// 정리 작업
|
|
});
|
|
|
|
// 커스텀 매처 (선택사항)
|
|
expect.extend({
|
|
// 날짜 문자열 검증
|
|
toBeValidDate(received) {
|
|
const isValid = !isNaN(Date.parse(received));
|
|
return {
|
|
message: () => `expected ${received} to be a valid date string`,
|
|
pass: isValid
|
|
};
|
|
},
|
|
|
|
// ID 검증
|
|
toBeValidId(received) {
|
|
const isValid = Number.isInteger(received) && received > 0;
|
|
return {
|
|
message: () => `expected ${received} to be a valid ID (positive integer)`,
|
|
pass: isValid
|
|
};
|
|
}
|
|
});
|