.toThrow(error) Also under the alias: .toThrowError(error) Use .toThrow to test that a function throws when it is called. For example, if we want to test that drinkFlavor('oct...
.rejects Use .rejects to unwrap the reason of a rejected promise so any other matcher can be chained. If the promise is fulfilled the assertion fails. For example, this code te...
.toHaveBeenCalled() Also under the alias: .toBeCalled() Use .toHaveBeenCalled to ensure that a mock function got called. For example, let's say you have a drinkAll(drink, fla...
How To Write Packages in Go Prerequisites Writing and Importing Packages Exported Code Conclusion How To Write Packages in Go Written by Gopher Guides A package is made up...
.toHaveBeenNthCalledWith(nthCall, arg1, arg2, ….) Also under the alias: .nthCalledWith(nthCall, arg1, arg2, …) If you have a mock function, you can use .toHaveBeenNthCalledWith...
如何在 Go 中编写包 前提条件 编写和导入软件包 可导出代码 总结 如何在 Go 中编写包 一个包由同一目录下的 Go 文件组成的,并且在文件开头有相同的包声明。你可以从包中加入额外的功能,使你的程序更加复杂。有些包可以通过 Go 标准库获得,因此在安装 Go 时就已经安装了。其他的可以用 Go 的go get 命令来安装。你也可以通过在同一...