fix(FEAT-QA-001): 隔离市场概览 E2E 测试时钟
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import type { INestApplication } from '@nestjs/common';
|
||||
import { Test } from '@nestjs/testing';
|
||||
import request from 'supertest';
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest';
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
|
||||
import { MarketOverviewController } from '../src/market-overview/market-overview.controller';
|
||||
import {
|
||||
@@ -12,9 +12,19 @@ import {
|
||||
describe('市场概览 HTTP API', () => {
|
||||
let app: INestApplication | undefined;
|
||||
|
||||
beforeEach(() => {
|
||||
// 固定到夹具交易日,避免测试随自然日期变化把正确的 delayed 响应误判为失败。
|
||||
vi.useFakeTimers();
|
||||
vi.setSystemTime(new Date('2026-08-18T03:00:00.000Z'));
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
await app?.close();
|
||||
app = undefined;
|
||||
try {
|
||||
await app?.close();
|
||||
} finally {
|
||||
app = undefined;
|
||||
vi.useRealTimers();
|
||||
}
|
||||
});
|
||||
|
||||
it('按模块返回指数和 TDX 来源元数据', async () => {
|
||||
|
||||
Reference in New Issue
Block a user