Files
bun.sh/test_options_syntax.test.js
Claude Bot 422e47961b Add support for test() options as second parameter
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>
2025-08-01 02:50:08 +00:00

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);
});