Giter Site home page Giter Site logo

bs-jest's Introduction

bs-jest - BuckleScript bindings for Jest Build Status

Very very experimental (yep, that's one less "very" than before! Progress!) and WIP

Status

  • Global: Fully implemented and tested, apart from require.*
  • Expect: Mostly implemented. Functionality that makes sense only for JS interop have been moved to ExpectJS. Some functionality does not make sense in a typed language, or is not possible to implement sensibly in ML.
  • Mock Functions: Experimental and unsafe implementation, very much in flux. The Jest bindings will most likely be relegated to the MockJs module as it's very quirky to use with native code. A separate native from-scratch implementation might suddenly appear as Mock.
  • The Jest Object: Fake timers are fully implemented and tested. Mock functionality has been moved to JestJs. It's mostly implemented, but experimental and largely untested.
  • [Snapshotting] Completely untested. Expect functions exist, but there's currently no way to implement custom snapshot serializers.

Example

(* OCaml *)
open Jest

let _ =

describe "Expect" (fun () -> 
  let open Expect in

  test "toBe" (fun () ->
    expect (1 + 2) |> toBe 3);
);

describe "Expect.Operators" (fun () -> 
  let open Expect in
  let open! Expect.Operators in

  test "==" (fun () ->
    expect (1 + 2) == 3);
);
/* Reason */
open Jest;

let _ =

describe "Expect" (fun () => {
  open Expect;
	
  test "toBe" (fun () =>
    expect (1 + 2) |> toBe 3)
});
    
describe "Expect.Operators" (fun () => {
  open Expect;
  open! Expect.Operators;
  
  test "==" (fun () =>
    expect (1 + 2) === 3)
});

See the tests for more examples.

Installation

npm install --save-dev bs-jest

Then add bs-jest to bs-dev-dependencies in your bsconfig.json:

{
  ...
  "bs-dev-dependencies": ["bs-jest"]
}

Then add __tests__ to sources in your bsconfig.json:

"sources": [
  {
    "dir": "src"
  },
  {
    "dir": "__tests__",
    "type": "dev"
  }
]

Usage

Put tests in a __tests__ directory and use the suffix *test.ml/*test.re (Make sure to use valid module names. e.g. <name>_test.re is valid while <name>.test.re is not). When compiled they will be put in a __tests__ directory under lib, with a *test.js suffix, ready to be picked up when you run jest. If you're not already familiar with Jest, see the Jest documentation.

Contribute

git clone https://github.com/reasonml-community/bs-jest.git
cd bs-jest
npm install

Then build and run tests with npm test, start watchers for bsband jest with npm run watch:bsb and npm run watch:jest respectively. Install screen to be able to use npm run watch:screen to run both watchers in a single terminal window.

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.