jhnns / rewire

Easy monkey-patching for node.js unit tests
MIT License
3.08k stars 128 forks source link

NEW Add support for .ts files #204

Closed dhensby closed 1 year ago

dhensby commented 2 years ago

When using rewire with typescript an error is thrown about assigning values to consts when trying to override top level variables.

This is because rewire is not intercepting and re-writing the compiled Typescript.

This change brings in support for .ts files by specifically overriding the .ts compile call and rewriting the compiled typescript from ts-node.

The test provided is just a copy of the coffeescript test but for the TS file. Without the patch to moduleEnv.js the assign to const error is thrown.

coveralls commented 1 year ago

Coverage Status

coverage: 98.063% (-0.7%) from 98.721% when pulling 2d7729f7c9e2ac03713d9644dcec1361b9cdb504 on dhensby:pulls/ts-support into 092e554955db2591d09b57d3b87a575ee0d510a9 on jhnns:master.

jhnns commented 1 year ago

Awesome. Great work, thank you :) Shipped with v7.0.0 🚀