Skip to content

Problem with es6 modules #63

@ZielonyBuszmen

Description

@ZielonyBuszmen

Hi!
I have small problem with bs-jest.

In my bsconfig.json I have es6 modules:

  "package-specs": {
    "module": "es6",
    "in-source": true
  },

When I run tests, it gives me the error like below:

$ jest
 FAIL  __tests__/Template_test.bs.js
  ● Test suite failed to run

    ....../node_modules/@glennsl/bs-jest/src/jest.js:3
    import * as List from "bs-platform/lib/es6/list.js";
    ^^^^^^

    SyntaxError: Cannot use import statement outside a module

      1 | // Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE
      2 | 
    > 3 | import * as Jest from "@glennsl/bs-jest/src/jest.js";
        | ^
      4 | 
      5 | Jest.describe("TestSuite", (function (param) {
      6 |         return Jest.test("test", (function (param) {

      at ScriptTransformer._transformAndBuildScript (node_modules/@jest/transform/build/ScriptTransformer.js:537:17)
      at ScriptTransformer.transform (node_modules/@jest/transform/build/ScriptTransformer.js:579:25)
      at Object.<anonymous> (__tests__/Template_test.bs.js:3:1)

Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        0.468s, estimated 2s
Ran all test suites.

When I change module to commonjs, everything starts working. (I can't do this permamently, because I have own bindings, that not compatible with commonjs)

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