How can I start and abandon a child workflow but still make it a skip time in unit tests?

I have a workflow that starts a child workflow and abandons it. In my unit tests, I want to test them both, but since the child workflow starts with .start it doesn’t support automatic time-skipping and waits for sleep commands. How can I enable time-skipping for the child workflow?

workflows.ts

const childWorkflow = async () => {
  ...some logic...
  // waits in the tests
  await sleep(15000);
  ...some logic...
};

const parentWorkflow = async () => {
  ...some logic...
  // doesn't wait in tests
   await sleep(10000);
  ...some logic...
  const child = await startChild(childWorkflow.name, {
    args: ['arg1'],
    parentClosePolicy: ParentClosePolicy.PARENT_CLOSE_POLICY_ABANDON,
    cancellationType: ChildWorkflowCancellationType.ABANDON,
  });
  return {
    providerWorkflowDetails: {id: child.workflowId, runId: child.firstExecutionRunId}
  }
};

workflows.test.ts

const execute = async (): Promise<void> => {
  const worker = await Worker.create({
    connection: testEnv.nativeConnection,
    taskQueue: 'test',
    workflowsPath: require.resolve('./workflows.ts'),
    activities,
  });
  return await worker.runUntil(async (): Promise<void> => {
    const response = await testEnv.client.workflow.execute(parentWorkflow.name, {
      workflowId: uuidv4(),
      taskQueue: 'test',
    });
    if (response?.providerWorkflowDetails) {
      const providerWorkflow = testEnv.client.workflow.getHandle(
        response.providerWorkflowDetails.id,
        response.providerWorkflowDetails.runId,
      );
      await providerWorkflow.result();
    }
  });
};

Time starts skipping as soon as you wait for the workflow’s result (e.g. by calling result or (done internally by) execute).

If this isn’t working for you there might be a bug in the test server.

I made it work by starting a new test env for each test.

Feel free to submit a bug report with a minimal reproduction at GitHub - temporalio/sdk-java: Temporal Java SDK (which is the repo where the test server is implemented).

Thanks!