syntax-tree/unist-builder

Error while running tests with unist-builder version 3.0.0

LokeshNSF opened this issue · 1 comments

Initial checklist

Affected packages and versions

3.0.0

Link to runnable example

No response

Steps to reproduce

Using jest for running the test throws error for unist-builder version 3.0.0. The same used to work fine for 2.0.3 version,
Error below,
Details:

/Users/lokeshkumar.n/mine/sandbox/doc-framework-monorepo/packages/@salesforcedocs/markdown-compiler/node_modules/unist-builder/index.js:16
export var u = /**
^^^^^^

SyntaxError: Unexpected token 'export'

  3 |
> 4 | import {u} from 'unist-builder';
    | ^

This is the error from Jest,
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.

I tried configuring transform option for unist-builder to use babel-jest, but still same problem persists for version 3.0.0

Expected behavior

Tests should be able to use the version 3.0.0

Actual behavior

Throws error while running tests using jest.

Runtime

Node v14

Package manager

yarn v1

OS

macOS

Build and bundle tools

Other (please specify in steps to reproduce)