Skip to content

Commit b14e95a

Browse files
committed
fix e2e tests
1 parent f13f7c7 commit b14e95a

5 files changed

Lines changed: 60 additions & 18 deletions

File tree

jest.config.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/** @type {import('ts-jest').JestConfigWithTsJest} */
2+
module.exports = {
3+
preset: "ts-jest",
4+
testEnvironment: "node",
5+
testMatch: ["**/tests/**/*.spec.ts"],
6+
moduleFileExtensions: ["ts", "tsx", "js", "jsx", "json", "node"],
7+
transform: {
8+
"^.+\\.tsx?$": [
9+
"ts-jest",
10+
{
11+
tsconfig: "tsconfig.base.json",
12+
},
13+
],
14+
},
15+
};

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
"test": "npm run test --workspaces",
1414
"test:unit": "npm run test:unit --workspaces --if-present",
1515
"test:e2e": "./scripts/test-e2e.sh",
16-
"test:e2e:one": "jest test/e2e --runInBand --detectOpenHandles --testNamePattern",
16+
"test:e2e:internal": "jest tests/e2e --runInBand --detectOpenHandles",
17+
"test:e2e:one": "jest tests/e2e --runInBand --detectOpenHandles --testNamePattern",
1718
"lint": "eslint . --ext .js,.jsx,.ts,.tsx",
1819
"pretty": "prettier --list-different \"**/*.{ts,tsx,js,jsx,json,md}\"",
1920
"pretty-fix": "prettier --write \"**/*.{ts,tsx,js,jsx,json,md}\"",

packages/durabletask-js/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"prebuild": "node -p \"'// Auto-generated by prebuild\\nexport const SDK_VERSION = ' + JSON.stringify(require('./package.json').version) + ';\\nexport const SDK_PACKAGE_NAME = ' + JSON.stringify(require('./package.json').name) + ';'\" > src/version.ts",
1616
"build": "npm run prebuild && npm run clean && tsc -p tsconfig.build.json && npm run copy-proto",
1717
"test": "jest --runInBand --detectOpenHandles",
18-
"test:unit": "jest test/unit --runInBand --detectOpenHandles"
18+
"test:unit": "jest test --runInBand --detectOpenHandles"
1919
},
2020
"engines": {
2121
"node": ">=22.0.0"
Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,27 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License.
33

4-
import { TaskHubGrpcClient } from "./client/client";
5-
import { TaskHubGrpcWorker } from "./worker/task-hub-grpc-worker";
6-
import { OrchestrationContext } from "./task/context/orchestration-context";
7-
import { ActivityContext } from "./task/context/activity-context";
4+
// Client and Worker
5+
export { TaskHubGrpcClient } from "./client/client";
6+
export { TaskHubGrpcWorker } from "./worker/task-hub-grpc-worker";
87

9-
export { TaskHubGrpcClient, TaskHubGrpcWorker, OrchestrationContext, ActivityContext };
8+
// Contexts
9+
export { OrchestrationContext } from "./task/context/orchestration-context";
10+
export { ActivityContext } from "./task/context/activity-context";
11+
12+
// Orchestration types and utilities
13+
export { PurgeInstanceCriteria } from "./orchestration/orchestration-purge-criteria";
14+
export { OrchestrationStatus } from "./orchestration/enum/orchestration-status.enum";
15+
16+
// Proto types (for advanced usage)
17+
export { OrchestrationStatus as ProtoOrchestrationStatus } from "./proto/orchestrator_service_pb";
18+
19+
// Task utilities
20+
export { getName, whenAll, whenAny } from "./task";
21+
export { Task } from "./task/task";
22+
23+
// Types
24+
export { TOrchestrator } from "./types/orchestrator.type";
25+
export { TActivity } from "./types/activity.type";
26+
export { TInput } from "./types/input.type";
27+
export { TOutput } from "./types/output.type";

tests/e2e/orchestration.spec.ts

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License.
33

4-
import { TaskHubGrpcClient } from "../../src/client/client";
5-
import { PurgeInstanceCriteria } from "../../src/orchestration/orchestration-purge-criteria";
6-
import { OrchestrationStatus } from "../../src/proto/orchestrator_service_pb";
7-
import { OrchestrationStatus as RuntimeStatus } from "../../src/orchestration/enum/orchestration-status.enum";
8-
import { getName, whenAll, whenAny } from "../../src/task";
9-
import { ActivityContext } from "../../src/task/context/activity-context";
10-
import { OrchestrationContext } from "../../src/task/context/orchestration-context";
11-
import { Task } from "../../src/task/task";
12-
import { TOrchestrator } from "../../src/types/orchestrator.type";
13-
import { TaskHubGrpcWorker } from "../../src/worker/task-hub-grpc-worker";
4+
import {
5+
TaskHubGrpcClient,
6+
TaskHubGrpcWorker,
7+
PurgeInstanceCriteria,
8+
ProtoOrchestrationStatus as OrchestrationStatus,
9+
OrchestrationStatus as RuntimeStatus,
10+
getName,
11+
whenAll,
12+
whenAny,
13+
ActivityContext,
14+
OrchestrationContext,
15+
Task,
16+
TOrchestrator,
17+
} from "@microsoft/durabletask-js";
1418

1519
describe("Durable Functions", () => {
1620
let taskHubClient: TaskHubGrpcClient;
@@ -421,7 +425,8 @@ describe("Durable Functions", () => {
421425
taskHubWorker.addActivity(plusOne);
422426
await taskHubWorker.start();
423427

424-
const startTime = new Date(Date.now());
428+
// Set startTime slightly in the past to account for clock drift
429+
const startTime = new Date(Date.now() - 1000);
425430
const id = await taskHubClient.scheduleNewOrchestration(orchestrator, 1);
426431
const state = await taskHubClient.waitForOrchestrationCompletion(id, undefined, 30);
427432

@@ -478,6 +483,9 @@ describe("Durable Functions", () => {
478483
runtimeStatuses.push(RuntimeStatus.TERMINATED);
479484
runtimeStatuses.push(RuntimeStatus.COMPLETED);
480485

486+
// Add a small delay to ensure the orchestrations are fully persisted
487+
await new Promise((resolve) => setTimeout(resolve, 1000));
488+
481489
criteria.setCreatedTimeTo(new Date(Date.now()));
482490
criteria.setRuntimeStatusList(runtimeStatuses);
483491
purgeResult = await taskHubClient.purgeOrchestration(criteria);

0 commit comments

Comments
 (0)