npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@reason-native/rely

v3.2.1

Published

A native Reason test runner that is heavily inspired by Jest

Downloads

52

Readme

@reason-native/rely

Detailed docs can be found at https://reason-native.com/docs/rely/

Installation

We recommend that you use esy to handle your package management. To install esy using npm, run

npm install -g esy

Add it as a dependency to your package.json (or esy.json) and run esy install. If you don't want to distribute your tests as part of your release, you can utilize multiple sandboxes and .opam files to separate your dependencies

package.json

...

dependencies": {
    ...
    "@reason-native/rely": "*",
    ...
},
...

Creating a test package

Let's start by creating a library for our tests. First create an opam file for your test package (it should be empty). Then let's create a directory called test and create a dune file to define compilation targets for our test library and executable (if you wish to use another build system, the important thing here is to pass the -linkall flag to the compiler)

│
├─my-lib-test.opam
├─test/
│   dune
│

dune

(library
   (name MyLibTest)
   (public_name my-lib-test.lib)
   ; the linkall flag ensures that all of our tests are compiled and the
   ; -g flag emits debugging information
   (ocamlopt_flags -linkall -g)
   ; you will want to depend on the library you are testing as well, however for
   ; the purposes of this example we are only depending on the test runner itself
   (libraries rely.lib )
   (modules (:standard \ RunTests))
)
(executable
  ; the for the library is automatically detected because of the name, but we
  ; need to explicitly specify the package here
  (package my-lib-test)
  (name RunTests)
  (public_name RunTests.exe)
  (libraries
    my-lib-test.lib
  )
  (modules RunTests)
)

Now let's create a file to initialize the test framework. Here we are specifying where snapshots should be stored as well as the root directory of your project for the formatting of terminal output.

│
├─my-lib-test.opam
├─test/
│   dune
│   TestFramework.re

TestFramework.re

include Rely.Make({
  let config =
    Rely.TestFrameworkConfig.initialize({
      snapshotDir: "path/to/test/lib/__snapshots__",
      projectDir: "path/to/your/project"
    });
});

Now we can finally write our first test!

│
├─my-lib-test.opam
├─test/
│   dune
│   TestFramework.re
│   MyFirstTest.re
open TestFramework;

describe("my first test suite", ({test}) => {
  test("1 + 1 should equal 2", ({expect}) => {
    expect.int(1 + 1).toBe(2);
  });
});

From here let's create an executable to actually run our tests (the name of this file corresponds to the name specified in the executable stanza in the dune file).

│
├─my-lib-test.opam
├─test/
│   dune
│   TestFramework.re
│   MyFirstTest.re
│   RunTests.re

RunTests.re

MyLibTest.TestFramework.cli()

Finally we can run esy build && esy x RunTests.exe to build and run our tests.

Developing:

npm install -g esy
git clone <this-repo>
esy install
esy build

Running Tests:

esy test

License

@reason-native/rely is MIT licensed, as found in the LICENSE file at the root of the reason-native repository.