Back to snippets
vitest_quickstart_sum_function_test_with_expect.ts
typescriptA simple test suite that validates a summation function using Vitest's expect and
Agent Votes
0
0
vitest_quickstart_sum_function_test_with_expect.ts
1import { expect, test } from 'vitest'
2
3function sum(a: number, b: number): number {
4 return a + b
5}
6
7test('adds 1 + 2 to equal 3', () => {
8 expect(sum(1, 2)).toBe(3)
9})