You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My assumption is that this is happening because the task is running from the dist folder rather than from the source (as setup in nyc)
Everything else in my project works fine (I can basically ignore dist during tests) and running everything from ts.
On the other hand, if I try to run MockTestRunner & TaskMockRunner with the ts files I get this:
For help, see: https://nodejs.org/en/docs/inspector
Debugger attached.
Waiting for the debugger to disconnect...
/Users/marco/Dev/typescript-node-template/test/setup/task-mock-runner.ts:1
import tmrm = require("azure-pipelines-task-lib/mock-run");
^^^^^^
SyntaxError: Cannot use import statement outside a module
at Object.compileFunction (node:vm:360:18)
at wrapSafe (node:internal/modules/cjs/loader:1126:15)
at Module._compile (node:internal/modules/cjs/loader:1162:27)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1252:10)
at Module.load (node:internal/modules/cjs/loader:1076:32)
at Function.Module._load (node:internal/modules/cjs/loader:911:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:22:47
I wonder if there's anything I'm missing or this is really not supported and won't be?
Any inputs are appreciated.
Example project attached. Check commented lines for more info
Did a little more digging and found that the issue #843 could actually fix my problem.
TaskMockRunner would work fine referencing the ts task file, but there's no way to assert what the task did... so maybe improving the TaskMockRunner would resolve it
I've ended up writing my own TaskMocker using sinon and proxyquire which doesn't require running the task in a subprocess. Leaving it here if anyone is interested
Hi,
I've been banging my head trying to move my project to esm using Mocha + ts-node and run tests before transpiling
@DmitriiBobreshev maybe you can help me as you did a lot of work in this area here 7c0de0d
Basically, if I follow the docs: https://learn.microsoft.com/en-us/azure/devops/extend/develop/add-build-task?view=azure-devops and setup mocha + nyc I get everything working, but basically no coverage for the ts files
My assumption is that this is happening because the task is running from the dist folder rather than from the source (as setup in nyc)
Everything else in my project works fine (I can basically ignore dist during tests) and running everything from ts.
On the other hand, if I try to run MockTestRunner & TaskMockRunner with the ts files I get this:
I wonder if there's anything I'm missing or this is really not supported and won't be?
Any inputs are appreciated.
Example project attached. Check commented lines for more info
Thank you
MockTestRunner-issue-with-ts.zip
The text was updated successfully, but these errors were encountered: