Closed alessiostalla closed 7 months ago
How do you run Jest? What I do in my VS Code extension (where I import antlr4ng just like you above) is:
node --no-warnings --experimental-vm-modules node_modules/jest/bin/jest.js --no-coverage
Additionally (to allow using TypeScript for tests and source files), I have a jest config file with a "transform" entry:
transform: {
'\\.ts?$': ['ts-jest', { useESM: true }]
},
See the full setup here. You need to install ts-jest
as a dev dependency.
Thanks, I managed to get it working! Now I have other issues, but they're unrelated :)
Did it work with what I suggested or did you have to find a different solution?
A similar solution I copied from antlr4-c3 :)
I've tried with Mocha and Jest (ts-jest) but both fail loading antlr4ng-generated parsers with ESM-related issues. I'm not sure how to tackle the problem. E.g. with Jest I get
Is there some recommended setup for using antlr4ng in tests? Note that the non-test build apparently succeeds (maybe it would later fail when linked, or at runtime).