fix(FEAT-QA-001): 隔离市场概览 E2E 测试时钟

This commit is contained in:
2026-08-24 17:53:09 +08:00
parent 7904571ddd
commit 368672f001
19 changed files with 408 additions and 3 deletions
@@ -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 () => {