24
src/config/viteProxyConfig.test.ts
Normal file
24
src/config/viteProxyConfig.test.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
import viteConfig from '../../vite.config';
|
||||
|
||||
describe('vite dev api proxy', () => {
|
||||
it('forwards the profile main route to the Rust API server', async () => {
|
||||
const resolvedConfig =
|
||||
typeof viteConfig === 'function'
|
||||
? await viteConfig({ command: 'serve', mode: 'test' })
|
||||
: viteConfig;
|
||||
|
||||
// 中文注释:`/api/profile/*` 是“我的”和“存档”页面的主链路由;
|
||||
// 本地 Vite 若漏配代理,会把请求回退到 index.html,前端再按 JSON 解析就会报 `Unexpected token '<'`。
|
||||
expect(resolvedConfig.server?.proxy).toEqual(
|
||||
expect.objectContaining({
|
||||
'/api/profile': expect.objectContaining({
|
||||
target: expect.any(String),
|
||||
changeOrigin: true,
|
||||
secure: false,
|
||||
}),
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user