mit einem Klick
testing
Write TypeScript runtime and type tests
Mit Codex oder Claude installieren Kopieren Sie diesen Prompt, fügen Sie ihn in Codex, Claude oder einen anderen Assistant ein und lassen Sie die Skill-Seite prüfen und installieren.
Menü
Write TypeScript runtime and type tests
Mit Codex oder Claude installieren Kopieren Sie diesen Prompt, fügen Sie ihn in Codex, Claude oder einen anderen Assistant ein und lassen Sie die Skill-Seite prüfen und installieren.
Basierend auf der SOC-Berufsklassifikation
| name | testing |
| description | Write TypeScript runtime and type tests |
Write TypeScript runtime and type tests for this project.
import * as test from "bun:test"
Use test.it for individual tests and test.describe for grouping:
test.describe("MyModule", () => {
test.it("should do something", () => {
// test body
})
})
Never use test.test - always use test.it.
Put each method call on a new line with 2-space indentation:
test.expect(value).toBe(expected)
test.expect(result).toEqual({ foo: "bar" })
test.expect(() => riskyOperation()).toThrow("error message")
Use expect-type for compile-time type checking. Inline types directly - no type aliases:
// Check a value matches a type
type.expectTypeOf(someValue).toMatchObjectType<ExpectedType>()
// Check two types are exactly equal
type.expectTypeOf<ActualType>().toMatchObjectType<ExpectedType>()
// Check a type extends another (less strict)
type.expectTypeOf<SubType>().toExtend<SuperType>()
Avoid variable names that shadow imports. Use descriptive suffixes:
// Bad - shadows `test` import
const test = Route.add("/test", Route.get(Route.text("test")))
// Good
const testRoute = Route.add("/test", Route.get(Route.text("test")))
When testing multiple exported functions or logic, use describe() at the root:
// when testing a function, use its reference:
test.describe(PathPattern.parseSegment, () => {})
test.describe("Params", () => {})
Keep describe() blocks flat and never wrap them in describe(MODULE_NAME)
Co-locate tests with source files: Module.test.ts alongside Module.ts