anyone have any difficulty w/ jest output? i've no...
# typescript
anyone have any difficulty w/ jest output? i've noticed that when i'm using ts-jest, if i import any pulumi resource or create a pulumi component during a test run (with mocks), it garbles the stack trace. when i remove the pulumi modules, the stack trace is fine
seems to also happen with babel-typescript
it appears to actually be related to the call to
removing the
call causes the errors to appear in their correct place (as long as it's not actually creating pulumi resources, in which case you get the pulumi context error)
i submitted a bug report for this
Is it due to the asynchronous nature of Pulumi? You may find it better to use
when you can, since then Pulumi controls when the text is sent to the console.
no, it's not outputting any of the test errors correctly
removing the pulumi import fixes the issue, which is strange
i thought it was the mocks at first, but it's including pulumi into a test file that does it
import * as pulumi from '@pulumi/pulumi'
trying ts-mocha now, but i'm having problems with paths with that
I use Mocha without this issue. Not ts-mocha though.
yeah, thats why i switched
i remember you saying you were using it with success, and the examples use mocha. i'd rather use jest, but, if it is what it is 🤷
Do note that (afaik) Mocha doesn't yet support module esnext or any of the new values for module. I use a separate tsconfig.test.json that specifies commonjs for module.
thank you for the heads up there
👍 1
do you use paths a lot in your project? wondering if there's something i'm missing, i just got the example test framework to work with a path definition but my project is still having trouble. calling mocha with
npx mocha -r ts-node/register -r tsconfig-paths/register {test_glob}
I've never got them working in my projects, but the project I'm working on now has them working. Not using registering anything, just using node 14.
And typescript 4.6.2.
I'm a newbie in the node/typescript area. Not clear on how it hangs together. But baseUrl/paths is something I tried to get working a few times, and never could; but it's just working now, on this project that someone else created. It's not really configured much at all, it just works... The only thing different about it compared to mine, is that it uses commonjs everywhere, when all my projects use esnext.
what's the test command?
i would expect you'd have to run
-r ts-node/register
at least
typically speaking you have to transpile to JS before node will run it. ts-node will run typescript without transpilation
In package.json scripts section:
"test": "env TS_NODE_PROJECT=\"tsconfig.test.json\" node --trace-warnings --unhandled-rejections=strict node_modules/mocha/bin/_mocha --spec \"./**/*.spec.ts\"",
Ah, it's in my .mocharc.json:
Copy code
  "parallel": false,
  "extension": [
  "require": [
Forgot about that.
thank you!
ill give that a shot
interesting that it calls the bin directly
and that it sets the env var
so i managed to get mocha to run the tests, but still haven't gotten paths to work. as i keep most of my pulumi projects small, i've sort of chalked this up to an acceptable defect
however, at least i get the right stack trace now
and as a side bonus, mocha appears to be much faster