Skip to content

Error when using finish(fail) on master #99

Description

@carere

Hello, first of all, thx for your amazing work 👌🏾

I got some problem when testing async code as follow:

open GlennslRescriptJest.Jest

describe("Executing some code which return errors", _ => {
  testAsync("should properly trigger fail", finish => {
    finish(fail("some error"))
  })
})

which translates in following JS:

// Generated by ReScript, PLEASE EDIT WITH CARE

import * as Curry from "rescript/lib/es6/curry.js";
import * as Jest$GlennslRescriptJest from "@glennsl/rescript-jest/src/jest.mjs";

Jest$GlennslRescriptJest.describe(
  "Executing some code which return errors",
  function (param) {
    return Jest$GlennslRescriptJest.testAsync(
      "should properly trigger fail",
      undefined,
      function (finish) {
        return Curry._1(finish, Jest$GlennslRescriptJest.fail("some error"));
      }
    );
  }
);

export {};
/*  Not a pure module */

Errors with:

 FAIL  test/unit/some_test.test.mjs
  Executing some code which return errors
    ✕ should properly trigger fail (1 ms)

  ● Executing some code which return errors › should properly trigger fail

    ReferenceError: fail is not defined

      11 |       undefined,
      12 |       function (finish) {
    > 13 |         return Curry._1(finish, Jest$GlennslRescriptJest.fail("some error"));
         |                      ^
      14 |       }
      15 |     );
      16 |   }

      at affirm (node_modules/@glennsl/rescript-jest/src/jest.mjs:36:9)
      at node_modules/@glennsl/rescript-jest/src/jest.mjs:232:19
      at Module._1 (node_modules/rescript/lib/es6/curry.js:32:12)
      at test/unit/some_test.test.mjs:13:22
      at Module._1 (node_modules/rescript/lib/es6/curry.js:32:12)
      at Object.<anonymous> (node_modules/@glennsl/rescript-jest/src/jest.mjs:231:17)

Test Suites: 1 failed, 1 total
Tests:       1 failed, 1 total
Snapshots:   0 total
Time:        0.219 s, estimated 1 s

Here you can find my bsconfig.json:

{
  "name": "bijensu",
  "sources": [
    {
      "dir": "src",
      "subdirs": true
    },
    {
      "dir": "test",
      "subdirs": true,
      "type": "dev"
    }
  ],
  "suffix": ".mjs",
  "package-specs": {
    "module": "es6",
    "in-source": true
  },
  "bs-dev-dependencies": ["@glennsl/rescript-jest"],
  "bs-dependencies": ["@ryyppy/rescript-promise"],
  "warnings": {
    "error": "+101"
  }
}

And my package.json:

{
  "name": "test-rescript-jest",
  "type": "module",
  "scripts": {
    "build": "rescript",
    "clean": "rescript clean -with-deps",
    "start": "rescript build -w",
    "test:unit": "jest test/unit"
  },
  "devDependencies": {,
    "jest": "27.*",
    "rescript": "9.*",
    "@glennsl/rescript-jest": "glennsl/rescript-jest#master",
    "@ryyppy/rescript-promise": "2.*"
  },
  "jest": {
    "moduleFileExtensions": [
      "js",
      "mjs"
    ],
    "testMatch": [
      "**/test/**/*.test.mjs"
    ]
  }
}

As you can see, i use the master version of your package since npm can't find any 0.8 version on npm.org
And i also use open GlennslRescriptJest.Jest since Rescript cannot find Jest namespace.
My environnement is:
OS: Elementary OS 6 Odin (Ubuntu 20.04.3 LTS)
Node: v16.13.0 (with flag --experimental-vm-modules in order to use ESM module without babel)
Yarn: 1.22.17

Im available if you need more information about this issue 😉

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions