jest
const add = (a, b) => a + b;
test('Adds two numbers', () => {
expect(add(1, 2)).toBe(3);
});class Person {
constructor(name) {
this.name = name;
}
greet() {
return `Hello, ${this.name}!`;
}
}
test('Greets a person', () => {
const person = new Person('Jane');
expect(person.greet()).toBe('Hello, Jane!');
});