Code Monkey home page Code Monkey logo

rescript-vitest's Introduction

rescript-vitest

npm npm downloads license

ReScript bindings to Vitest

Prerequisite

ReScript v10.1+ is required since v1.0.0. To use Js.Promise2 and async/await for tests.

ReScript v11 can be used with "uncurried": false

Config

Configure with plain vite.config.js.

You can use vite-plugin-rescript to build ReScript automatically before the test.

Usage

You can find examples on tests

Basic

open Vitest

describe("Hello, Vitest", () => {
  test("This is a test case", t => {
    // t is `expect` object for suite-wide assertions
    t->assertions(3)

    // Test using the `Expect` module
    expect(1 + 2)->Expect.toBe(3)

    // There are some nested modules for specific type
    expect([1, 2, 3])
    ->Expect.Array.toContain(2)

    expect("Hello, ReScript-Vitest!")
    ->Expect.String.toContain("ReScript")

  // You can specify timeout for a test suite
  }, ~timeout=2000)
})

In-source testing (experimental)

Vitest support in-source testing

// This if block can be removed from production code.
// You need to define `import.meta.vitest` to `undefined`
if Vitest.inSource {
  open Vitest
  open Vitest.InSource

  test("In-source testing", _ => {
    expect(1 + 2)->Expect.toBe(3)
  })
}

LICENCE

MIT

rescript-vitest's People

Contributors

cometkim avatar illusionalsagacity avatar kingdutch avatar brettcannon avatar jihchi avatar jonesmelton avatar jmagaram avatar lgtm-com[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.