startest

Package Version Hex Docs Erlang-compatible JavaScript-compatible

🌠 A testing framework to help you shoot for the stars.

Installation

gleam add --dev startest

Features

Usage

import startest.{describe, it}
import startest/expect

// Inside of `test/my_project_test.gleam`:
pub fn main() {
  // Call `startest.run` inside of your `main` function.
  // Here we're using the default config, but you can customize this, as needed.
  startest.run(startest.default_config())
}

// Tests can be expressed using the `describe` API:
pub fn my_project_tests() {
  describe("My Project", [
    describe("2 + 2", [
      it("equals 4", fn() {
        2 + 2
        |> expect.to_equal(4)
      }),
    ]),
  ])
}

// You can also write tests as standalone functions.
// These functions must be public and have a name ending in `_test`:
pub fn a_standalone_test() {
  { "Hello, " <> "Joe!" }
  |> expect.to_equal("Hello, Joe!")
}

Migrating from gleeunit

If you’re coming from gleeunit, follow these steps for an easy migration to Startest:

  1. Install Startest with gleam add --dev startest
  2. Replace all imports of gleeunit/should with startest/expect
  3. Update gleeunit/should assertions to startest/expect
    • Consult the migration table down below for the equivalent assertions in Startest
  4. Remove gleeunit with gleam remove gleeunit
  5. Optionally, begin using the describe API to structure your tests
gleeunit/shouldstartest/expect
should.equalexpect.to_equal
should.not_equalexpect.to_not_equal
should.be_trueexpect.to_be_true
should.be_falseexpect.to_be_false
should.be_okexpect.to_be_ok
should.be_errorexpect.to_be_error
should.be_someexpect.to_be_some
should.be_noneexpect.to_be_none
should.failexpect.to_be_true(False) or panic

This conversion can typically be done with a find/replace:

- should.
+ expect.to_
Search Document