mirror of
https://github.com/oven-sh/bun
synced 2026-02-16 05:42:43 +00:00
Allows using test() with options as the second parameter:
- test("name", { timeout: 1000 }, () => { ... })
- test("name", 500, () => { ... })
While maintaining backward compatibility with the original syntax:
- test("name", () => { ... }, { timeout: 1000 })
- test("name", () => { ... }, 500)
This feature improves consistency with other testing frameworks
and provides a more intuitive parameter order.
Changes:
- Updated argument parsing in jest.zig createScope function
- Added TypeScript type overloads for test, test.only, test.skip, test.todo
- Added regression tests to ensure both syntaxes work
- Updated type tests to verify TypeScript compatibility
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
31 lines
808 B
JavaScript
31 lines
808 B
JavaScript
import { test, expect } from "bun:test";
|
|
|
|
// Test the original syntax (should still work)
|
|
test("original syntax - function as second parameter", () => {
|
|
expect(true).toBe(true);
|
|
}, { timeout: 1000 });
|
|
|
|
// Test the new syntax - options as second parameter
|
|
test("new syntax - options as second parameter", { timeout: 1000 }, () => {
|
|
expect(true).toBe(true);
|
|
});
|
|
|
|
// Test with number options
|
|
test("new syntax with number timeout", 500, () => {
|
|
expect(true).toBe(true);
|
|
});
|
|
|
|
// Test with todo
|
|
test.todo("todo with new syntax", { timeout: 1000 }, () => {
|
|
expect(true).toBe(true);
|
|
});
|
|
|
|
// Test with skip
|
|
test.skip("skip with new syntax", { timeout: 1000 }, () => {
|
|
expect(true).toBe(true);
|
|
});
|
|
|
|
// Test with only
|
|
test.only("only with new syntax", { timeout: 1000 }, () => {
|
|
expect(true).toBe(true);
|
|
}); |