export function solution(a: number, b: number): number {
return a + b;
}
src/solution.test.ts
import { solution } from './solution';
test('test1: adding positive numbers', () => {
expect(solution(1, 2)).toBe(3);
});
test('test2: adding negative numbers', () => {
expect(solution(-1, -2)).toBe(-3);
});
test('test3: adding a string and a number', () => {
// To handle this case, you might need to adjust the function or the test
// For demonstration, assuming the function strictly accepts numbers
// This test will fail and needs to be handled appropriately
// Alternatively, you can use type assertions or overloads
});
Launch Example
Example Query
Example Generation
package.json
tsconfig.json
src/solution.ts
src/solution.test.ts
Example Install Dependencies
Example Launch Compilation
Example Launch Test