Vitest’s in-source testing (if (import.meta.vitest)) lets you write unit tests alongside your code:
// Vitest in-source
export function add(a, b) { return a + b }
if (import.meta.vitest) {
const { it, expect } = import.meta.vitest
it('adds numbers', () => expect(add(1, 2)).toBe(3))
}
Scenetest is different - it runs assertions in the real browser during app execution:
// Scenetest
function Cart({ items }) {
should('cart has valid items', items.every(i => i.price > 0))
return <div>...</div>
}
Key differences:
Think of it this way: Vitest in-source testing is for unit tests of pure functions. Scenetest is for integration assertions that need the full browser environment and real app state.