cometkim / rescript-vitest

ReScript bindings to Vitest
MIT License
42 stars 9 forks source link

Cannot read properties of undefined (reading 'test') #10

Closed aaronabramov closed 1 year ago

aaronabramov commented 1 year ago

i'm new to ReScript and Vitest. i'm trying to to a simple setup for a new project but can't get past the runtime error.

test:

open Vitest

test("meow", t => {
  t->assertions(1)
  expect(1)->Expect.toBe(3)
})

.bs.js

// Generated by ReScript, PLEASE EDIT WITH CARE

import * as Vitest from "rescript-vitest/src/Vitest.bs.js";
import * as Vitest$1 from "vitest";

Vitest.test("meow", undefined, (function (t) {
        t.assertions(1);
        Vitest$1.expect(1).toBe(3);
      }));

export {

}
/*  Not a pure module */

vitest.config.ts

import { defineConfig } from "vitest/config";

export default defineConfig({
  test: {
    include: ["**/*.{test,spec}{,.bs}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}"],
  },
});
 FAIL  res/data/__tests__/basic.test.bs.js [ res/data/__tests__/basic.test.bs.js ]
TypeError: Cannot read properties of undefined (reading 'test')
 ❯ Runner_test node_modules/rescript-vitest/src/Vitest.bs.js:106:25
    104| }
    105|
    106| function Runner_testAsync(prim0, prim1, prim2) {
       |                         ^
    107|   Vitest.test(prim0, (function () {
    108|           return Curry._1(prim1, undefined);
 ❯ Module._3 node_modules/rescript/lib/es6/curry.js:131:12
 ❯ Module.test node_modules/rescript-vitest/src/Vitest.bs.js:148:25
 ❯ res/data/__tests__/basic.test.bs.js:6:8

I might have missed a dependency or maybe ther's a version mismatch?

aaronabramov commented 1 year ago

it does work after i downgraded vitest to vitest": "^0.28.1

cometkim commented 1 year ago

Since the package already has vitest as a dependency, you shouldn't add a new version.

Also note, this is a limitation caused by the curried function, there may be interface changes in the next major.

cometkim commented 1 year ago

Just released v1.2.0, which uses vitest 0.31.0