- Raise use-swipe-gesture mutation score to 66.13% (target 65%+) - Maintain use-reduced-motion mutation score at 76.32% (target 50%+) - Fix use-reduced-motion.ts ESLint set-state-in-effect warning - Add UJ-10 deep searcher journey (category browse → article read → content discovery) - Add 40 new test files (analytics, detail, sections, ui, lib components) - Update test-strategy-plan.md to v2.0 (sync test count to 1591) - Sync README.md with final release metrics Quality gates: TS 0 errors, ESLint 0 errors, 121 suites / 1591 tests passed
57 lines
1.5 KiB
JavaScript
57 lines
1.5 KiB
JavaScript
// @ts-nocheck
|
|
import http from 'k6/http';
|
|
import { check, sleep } from 'k6';
|
|
import { Rate, Trend } from 'k6/metrics';
|
|
|
|
const errorRate = new Rate('errors');
|
|
const responseTime = new Trend('response_time');
|
|
|
|
export const options = {
|
|
stages: [
|
|
{ duration: '2m', target: 100 }, // 2分钟内逐步增加到100用户
|
|
{ duration: '5m', target: 100 }, // 保持100用户5分钟
|
|
{ duration: '2m', target: 200 }, // 2分钟内增加到200用户
|
|
{ duration: '5m', target: 200 }, // 保持200用户5分钟
|
|
{ duration: '2m', target: 0 }, // 2分钟内减少到0
|
|
],
|
|
thresholds: {
|
|
http_req_duration: ['p(95)<500', 'p(99)<1000'], // 95%请求<500ms, 99%请求<1s
|
|
http_req_failed: ['rate<0.01'], // 错误率<1%
|
|
errors: ['rate<0.01'],
|
|
},
|
|
};
|
|
|
|
const BASE_URL = __ENV.BASE_URL || 'http://localhost:3000';
|
|
|
|
export default function () {
|
|
const pages = [
|
|
'/',
|
|
'/about',
|
|
'/services',
|
|
'/products',
|
|
'/news',
|
|
'/contact',
|
|
];
|
|
|
|
const page = pages[Math.floor(Math.random() * pages.length)];
|
|
const res = http.get(`${BASE_URL}${page}`, {
|
|
tags: { name: page },
|
|
});
|
|
|
|
const success = check(res, {
|
|
'status is 200': (r) => r.status === 200,
|
|
'response time < 500ms': (r) => r.timings.duration < 500,
|
|
});
|
|
|
|
errorRate.add(!success);
|
|
responseTime.add(res.timings.duration);
|
|
|
|
sleep(Math.random() * 3 + 1); // 1-4秒随机等待
|
|
}
|
|
|
|
export function handleSummary(data) {
|
|
return {
|
|
'performance/load-test-summary.json': JSON.stringify(data, null, 2),
|
|
};
|
|
}
|