Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not work with Jest in CommonJS #34

Open
LiKang6688 opened this issue Oct 18, 2022 · 5 comments
Open

Does not work with Jest in CommonJS #34

LiKang6688 opened this issue Oct 18, 2022 · 5 comments

Comments

@LiKang6688
Copy link

Details:

    .../node_modules/.pnpm/clet@1.0.1/node_modules/clet/lib/runner.js:1
    ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,jest){import { EOL } from 'os';
                                                                                      ^^^^^^

    SyntaxError: Cannot use import statement outside a module
@atian25
Copy link
Member

atian25 commented Oct 19, 2022

could you provide a mini example repository?

btw: plan to rewrite clet with ts then build esm and cjs, but honestly I don't have time recently.

@Mrtenz
Copy link

Mrtenz commented Mar 22, 2023

Was running into this as well. I had to force Jest to transform a bunch of dependencies (including clet), and patch clet to not use import.meta.

@Sweetog
Copy link

Sweetog commented Jul 1, 2023

@Mrtenz what do you mean you "patched" clet to not use import.meta? What doesn't the Babel transform @babel/plugin-syntax-import-meta work?

@Mrtenz
Copy link

Mrtenz commented Jul 1, 2023

@Sweetog We're not using Babel to run tests, so we can't use that. Instead, I created a Yarn patch:

https://github.com/MetaMask/snaps/blob/1a0dd93ba3841c387bf6803d1d154d369bc4e45a/.yarn/patches/clet-npm-1.0.1-8523231bdc.patch#L36

This line seemed to be unnecessary, and it works fine without.

@Sweetog
Copy link

Sweetog commented Jul 3, 2023

What are the ergonomics of best practices to clet to run in continuous integration environment? I do not need to use Jest, but I need to a "test runner" if you will. I could run a process that executes imports but than I might need to manage parallel tests running and consolidate assertion output and errors etc.

I definitely am having troubles using clet with my CLI and Jest because of ESM versus CommonJs mixture.

I have tried a plethora of babel-jest and babel transforms and just cannot get around the import.metaissue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants