Vue.js / Nuxt.js

Vue Testing

Vitest, Vue Test Utils, component testing, mocking, snapshot testing, E2E with Playwright

20 คำถามสัมภาษณ์·
Mid-Level
1

What is Vitest?

คำตอบ

Vitest is a modern unit testing framework designed specifically for Vite projects. It offers native ESM module compatibility, built-in TypeScript support, and ultra-fast execution thanks to its deep integration with Vite. Vitest provides a Jest-compatible API, making it easy to migrate existing projects while benefiting from superior performance.

2

What is the role of Vue Test Utils?

คำตอบ

Vue Test Utils is the official testing library for Vue.js that provides utilities to mount and interact with Vue components in a testing environment. It exposes methods like mount and shallowMount to render components, as well as APIs to simulate user interactions, verify props, capture emitted events, and inspect the rendered DOM. This library is essential for testing Vue components in isolation.

3

What is the main difference between mount and shallowMount?

คำตอบ

mount renders the complete component with all its child components recursively, creating a full DOM tree. shallowMount only renders the top-level component by automatically replacing all child components with empty stubs. Use shallowMount for strict unit tests where isolation is paramount and mount for integration tests where parent-child component interactions need to be verified.

4

How to configure Vitest in a Vue/Nuxt project?

5

Which wrapper method allows finding an element by its CSS selector?

+17 คำถามสัมภาษณ์

เชี่ยวชาญ Vue.js / Nuxt.js สำหรับการสัมภาษณ์ครั้งถัดไป

เข้าถึงคำถามทั้งหมด flashcards แบบทดสอบเทคนิค แบบฝึกหัด code review และตัวจำลองสัมภาษณ์

เริ่มใช้ฟรี