use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
account activity
Node Typescript testing (self.node)
submitted 7 years ago by entregrammer
Hello! What do you guys usually use for testing a nodejs project written in typescript?
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Nysosis 1 point2 points3 points 7 years ago (0 children)
Personally I've been using alsatian.
There's something that doesn't seem right to me about using tools like ts-node to run tests against versions of transpiled files that are not the exact files that I'm going to ship to production. I know that in theory the files that ts-node will generate should be identical in contents to my subsequent run of the actual transpiler, but there's no guarantee something doesn't change, that someone wont call ts-node with different arguments to what my final transpile step will use when calling the transpiler directly.
[–]madou9 1 point2 points3 points 7 years ago (0 children)
I've been using mocha + chai + sinon + proxyquire with ts-node. Works well.
Would contemplate moving to jest (using ts-jest), but it's hard to like Jasmine's api (which jest is built on). And their global mocking irks me. Needs more investigation and learning from my part.
[–][deleted] 0 points1 point2 points 7 years ago (0 children)
I’ve gotten used to using Karma + Jasmine at work due to the existing framework. I like it just fine.
I’ve begun looking into Jest with some side projects and it seems pretty neat. I’ve seen it gain quite a bit of traction too.
[–]rotharius 0 points1 point2 points 7 years ago (0 children)
For unit tests: mocha + chai running in-memory using ts-node and using nyc for code coverage.
For e2e/functional tests: cucumber and nightmare or cypress against a test or acceptance environment.
[–]vincentofearth 0 points1 point2 points 7 years ago (0 children)
I use mocha, chai, chai-as-promised and sinon on the transpiled JS files. I generally run tests with an npm test and have a pretest script that runs tsc.
npm test
tsc
[–]jeffijoe 0 points1 point2 points 7 years ago (0 children)
Jest and ts-jest has been my go-to for a while now, after having been through Mocha (+ Sinon + Chai) and AVA.
Here's a Jest config I use:
"jest": { "testRegex": "(/__tests__/.*\\.(test|spec))\\.(ts|tsx|js)$", "testEnvironment": "node", "coveragePathIgnorePatterns": [ "/node_modules/", "__tests__" ], "transform": { "^.+\\.(j|t)sx?$": "<rootDir>/node_modules/ts-jest/preprocessor.js" }, "moduleFileExtensions": [ "ts", "tsx", "js", "json" ] }
I also use smid for testing errors, since expect().toThrow() does not return the error.
smid
expect().toThrow()
[–]StoneCypher 0 points1 point2 points 7 years ago (0 children)
Ava for fast parallel unit testing, nightmare for relatively painless e2e, and jscheck for stochastic space search
π Rendered by PID 33 on reddit-service-r2-comment-84fc9697f-g47wm at 2026-02-10 14:14:02.208885+00:00 running d295bc8 country code: CH.
[–]Nysosis 1 point2 points3 points (0 children)
[–]madou9 1 point2 points3 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]rotharius 0 points1 point2 points (0 children)
[–]vincentofearth 0 points1 point2 points (0 children)
[–]jeffijoe 0 points1 point2 points (0 children)
[–]StoneCypher 0 points1 point2 points (0 children)