温馨提示:本站仅提供公开网络链接索引服务,不存储、不篡改任何第三方内容,所有内容版权归原作者所有
AI智能索引来源:http://www.bun.com/reference/bun/test/Matchers/toThrow
点击访问原文链接

Matchers.toThrow method | bun:test module | Bun

Matchers.toThrow method | bun:test module | BunBuildDocsReferenceGuidesBlogDiscord/bun:test/Matchers/toThrowMtoThrow

Search the reference...

/

BuildDocsReferenceGuidesBlogDiscord/bun:test/Matchers/toThrowMtoThrow

method

test.Matchers.toThrowtoThrow(expected?: unknown): void;Asserts that a function throws an error.

If expected is a string or RegExp, it will check the message property.If expected is an Error object, it will check the name and message properties.If expected is an Error constructor, it will check the class of the Error.If expected is not provided, it will check if anything has thrown.@param expectedthe expected error, error message, or error pattern

function fail() { throw new Error("Oops!"); } expect(fail).toThrow("Oops!"); expect(fail).toThrow(/oops/i); expect(fail).toThrow(Error); expect(fail).toThrow();

Resources

ReferenceDocsGuidesDiscordMerch StoreGitHubBlog 

Toolkit

RuntimePackage managerTest runnerBundlerPackage runner

Project

Bun 1.0Bun 1.1Bun 1.2Bun 1.3RoadmapContributingLicenseBaked with ❤️ in San Francisco

We're hiring →

智能索引记录