mirror of
https://github.com/affaan-m/everything-claude-code.git
synced 2026-04-13 13:23:31 +08:00
fix: harden unicode safety checks
This commit is contained in:
@@ -335,28 +335,28 @@ npm run test:coverage
|
||||
|
||||
## 应避免的常见测试错误
|
||||
|
||||
### ❌ 错误:测试实现细节
|
||||
### FAIL: 错误:测试实现细节
|
||||
|
||||
```typescript
|
||||
// Don't test internal state
|
||||
expect(component.state.count).toBe(5)
|
||||
```
|
||||
|
||||
### ✅ 正确:测试用户可见的行为
|
||||
### PASS: 正确:测试用户可见的行为
|
||||
|
||||
```typescript
|
||||
// Test what users see
|
||||
expect(screen.getByText('Count: 5')).toBeInTheDocument()
|
||||
```
|
||||
|
||||
### ❌ 错误:脆弱的定位器
|
||||
### FAIL: 错误:脆弱的定位器
|
||||
|
||||
```typescript
|
||||
// Breaks easily
|
||||
await page.click('.css-class-xyz')
|
||||
```
|
||||
|
||||
### ✅ 正确:语义化定位器
|
||||
### PASS: 正确:语义化定位器
|
||||
|
||||
```typescript
|
||||
// Resilient to changes
|
||||
@@ -364,7 +364,7 @@ await page.click('button:has-text("Submit")')
|
||||
await page.click('[data-testid="submit-button"]')
|
||||
```
|
||||
|
||||
### ❌ 错误:没有测试隔离
|
||||
### FAIL: 错误:没有测试隔离
|
||||
|
||||
```typescript
|
||||
// Tests depend on each other
|
||||
@@ -372,7 +372,7 @@ test('creates user', () => { /* ... */ })
|
||||
test('updates same user', () => { /* depends on previous test */ })
|
||||
```
|
||||
|
||||
### ✅ 正确:独立的测试
|
||||
### PASS: 正确:独立的测试
|
||||
|
||||
```typescript
|
||||
// Each test sets up its own data
|
||||
|
||||
Reference in New Issue
Block a user