monero-ts: Error importing monero-ts since updating Axios

Since the Axios update in v0.10.1, I’m hitting an error using monero-ts in haveno-ts:

 FAIL  src/HavenoClient.test.ts
  ● Test suite failed to run

    Jest encountered an unexpected token

    This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain JavaScript.

    By default, if Jest sees a Babel config, it will use that to transform your files, ignoring "node_modules".

    Here's what you can do:
     • If you are trying to use ECMAScript Modules, see https://jestjs.io/docs/en/ecmascript-modules for how to enable it.
     • To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
     • If you need a custom transformation specify a "transform" option in your config.
     • If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.

    You'll find more details and examples of these config options in the docs:
    https://jestjs.io/docs/en/configuration.html

    Details:

    /Users/woodser/git/haveno-ts/node_modules/axios/index.js:1
    ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import axios from './lib/axios.js';
                                                                                             ^^^^^^

    SyntaxError: Cannot use import statement outside a module

      51 | import assert from "assert";
      52 | import console from "console"; // import console because jest swallows messages in real time
    > 53 | import moneroTs from "monero-ts";
         | ^
      54 | import * as os from 'os';
      55 |
      56 | // ------------------------------ TEST CONFIG ---------------------------------

      at Runtime.createScriptFromCode (node_modules/jest-runtime/build/index.js:1350:14)
      at Object.<anonymous> (node_modules/monero-ts/src/main/ts/common/HttpClient.ts:7:1)
      at Object.<anonymous> (node_modules/monero-ts/index.ts:11:1)
      at Object.<anonymous> (src/HavenoClient.test.ts:53:1)

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 32 (32 by maintainers)

Most upvoted comments

Okay, I take this bounty offer and will take another look at haveno-ts.

My main problem is that your docker setup is using host networking which does not work in my macOS environment. Firstly I want to migrate the docker compose setup to use docker internal networking, then it will be better portable and testable

Built haveno and protobuf but fail with TypeError: Jest: a transform must export a process function.

I run out of time, will be back on Monday