Socket
Socket
Sign inDemoInstall

github.com/matryer/is

Package Overview
Dependencies
0
Alerts
File Explorer

Install Socket

Detect and block malicious and high-risk dependencies

Install

    github.com/matryer/is

Package is provides a lightweight extension to the standard library's testing capabilities. Comments on the assertion lines are used to add a description. The following failing test: Will output: The following code shows a range of useful ways you can use the helper methods:


Version published

Readme

Source

is GoDoc Go Report Card Build Status

Professional lightweight testing mini-framework for Go.

  • Easy to write and read
  • Beautifully simple API with everything you need: is.Equal, is.True, is.NoErr, and is.Fail
  • Use comments to add descriptions (which show up when tests fail)

Failures are very easy to read:

Examples of failures

Usage

The following code shows a range of useful ways you can use the helper methods:

func Test(t *testing.T) {

	is := is.New(t)

	signedin, err := isSignedIn(ctx)
	is.NoErr(err)            // isSignedIn error
	is.Equal(signedin, true) // must be signed in

	body := readBody(r)
	is.True(strings.Contains(body, "Hi there"))

}

Color

To turn off the colors, run go test with the -nocolor flag, or with the env var NO_COLOR (with any value).

go test -nocolor
NO_COLOR=1 go test

FAQs

Last updated on 16 May 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc