Skip to content

feat: vitest#7

Closed
zhangmo8 wants to merge 4 commits into
unocss:mainfrom
zhangmo8:test
Closed

feat: vitest#7
zhangmo8 wants to merge 4 commits into
unocss:mainfrom
zhangmo8:test

Conversation

@zhangmo8

@zhangmo8 zhangmo8 commented Nov 4, 2025

Copy link
Copy Markdown
Contributor

No description provided.

@netlify

netlify Bot commented Nov 4, 2025

Copy link
Copy Markdown

Deploy Preview for unocss-inspector ready!

Name Link
🔨 Latest commit e4582c7
🔍 Latest deploy log https://app.netlify.com/projects/unocss-inspector/deploys/6909c5c09e4907000813c556
😎 Deploy Preview https://deploy-preview-7--unocss-inspector.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@zyyv zyyv requested a review from Copilot November 4, 2025 08:00

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds Vitest testing infrastructure and improves error handling throughout the codebase. The changes include:

  • Setting up Vitest with configuration for testing Vue components and composables
  • Adding comprehensive error handling with try-catch blocks in critical functions
  • Improving type safety by replacing any types with proper TypeScript types
  • Updating dependencies to newer versions

Reviewed Changes

Copilot reviewed 16 out of 18 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
vitest.config.ts Adds Vitest configuration with Vue support, happy-dom environment, and coverage settings
pnpm-workspace.yaml Updates dependency versions and adds test-related packages to catalog
package.json Adds test dependencies and updates package manager version
packages/unplugin/src/index.ts Adds error handling to HTML transformation and file loading operations
packages/unplugin/src/core/options.ts Replaces any type with proper Component type from Vue
packages/unplugin/scripts/copy-from-inspector.ts Improves error handling by replacing any with unknown
packages/inspector/src/composables/exports/element.ts Adds try-catch error handling to triggering and style-setting functions
packages/inspector/src/composables/classList.ts Wraps classList update logic in try-catch block
packages/inspector/src/composables/attributes.ts Adds error handling to attribute update function
packages/inspector/src/components/panels/InlineStyles.vue Adds proper type interface for VNode elements
packages/inspector/src/components/panels/DomTree.vue Replaces any cast with proper `HTMLElement
packages/inspector/src/components.d.ts Adds TypeScript declaration for Vue SFC imports
packages/inspector/src/Inspector.vue Adds comprehensive error handling to all event handlers and UI operations
packages/inspector/tests/** Adds test suites for composables and components

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

}
catch (error) {
console.error('[UnoCSS Inspector] Failed to start selecting:', error)
stopSelecting()

Copilot AI Nov 4, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the startSelecting function's catch block, calling stopSelecting() could potentially throw another error and mask the original error. The catch block at line 97-100 should handle errors more defensively. Consider wrapping stopSelecting() in its own try-catch or ensuring it cannot throw.

Suggested change
stopSelecting()
try {
stopSelecting()
} catch (stopError) {
console.error('[UnoCSS Inspector] Failed to stop selecting after startSelecting error:', stopError)
}

Copilot uses AI. Check for mistakes.
}
catch (error) {
console.error('[UnoCSS Inspector] Error in handleClick:', error)
stopSelecting()

Copilot AI Nov 4, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the handleClick function's catch block, calling stopSelecting() could potentially throw another error and mask the original error. The catch block at line 157-160 should handle errors more defensively. Consider wrapping stopSelecting() in its own try-catch or ensuring it cannot throw.

Suggested change
stopSelecting()
try {
stopSelecting()
}
catch (stopError) {
console.error('[UnoCSS Inspector] Error in stopSelecting (called from handleClick catch):', stopError)
}

Copilot uses AI. Check for mistakes.
y: Math.max(0, Math.min(newY, windowHeight.value - controlSize)),
catch (error) {
console.error('[UnoCSS Inspector] Error in handleControlDrag:', error)
stopControlDrag()

Copilot AI Nov 4, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the handleControlDrag function's catch block, calling stopControlDrag() could potentially throw another error and mask the original error. The catch block at line 210-213 should handle errors more defensively. Consider wrapping stopControlDrag() in its own try-catch or ensuring it cannot throw.

Suggested change
stopControlDrag()
try {
stopControlDrag()
} catch (stopError) {
console.error('[UnoCSS Inspector] Error in stopControlDrag during handleControlDrag error handling:', stopError)
}

Copilot uses AI. Check for mistakes.
@zhangmo8 zhangmo8 closed this Apr 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants