Hello, I’m trying to run a simple workflow test and I find that there are linting and typescript errors when using the @temporalio/testing module.
So far, I’m faced with two issues and this post is about the first issue. The second issue is Workflow Testing Framework violates typescript checks? "duplicate name 'ActivityHeartbeat' in Namespace coresdk"
TS error: @temporalio/worker/lib/connection").NativeConnection is not assignable to type @temporalio/testing/node_modules/@temporalio/worker/lib/connection").NativeConnection
This error shows when using the WorkerOptions from @temporalio/testing, the result of augmentWorkerOptions() for the Worker.create(workerOptions) call.
const workflowCoverage = new WorkflowCoverage();
const workerOptions = workflowCoverage.augmentWorkerOptions({
connection: nativeConnection,
taskQueue: 'test',
workflowsPath: require.resolve('src/workflows/ev-charger/installation-workflow'),
activities: {
getNextProvider: () => serviceProviderData,
},
});
const worker = await Worker.create(workerOptions);
I worked around this by importing WorkerOptions from the same package…
import { Worker, WorkerOptions } from '@temporalio/worker';
…and declaring the testing instance version of WorkerOptions as the worker’s version of WorkerOptions.
const worker = await Worker.create(workerOptions as WorkerOptions);
The gist seems to be: the testing module has the node_module dependency to the same NativeConnection that is in @temporalio/worker/lib/connection so even though the class is the same, typescript doesn’t recognize that it is so.
Thank you for taking a look at this!