1- import * as fs from 'fs/promises' ;
21import path from 'path' ;
32import * as grpc from '@grpc/grpc-js' ;
43import asyncRetry from 'async-retry' ;
54import { v4 as uuid4 } from 'uuid' ;
65import { Client , Connection } from '@temporalio/client' ;
7- import { historyToJSON } from '@temporalio/common/lib/proto-utils' ;
86import * as iface from '@temporalio/proto' ;
97
108// Re-export from test-helpers
@@ -13,53 +11,32 @@ export {
1311 waitUntil ,
1412 u8 ,
1513 approximatelyEqual ,
16- isSet ,
1714 RUN_INTEGRATION_TESTS ,
1815 REUSE_V8_CONTEXT ,
1916 RUN_TIME_SKIPPING_TESTS ,
20- TESTS_CLI_VERSION ,
21- TESTS_TIME_SKIPPING_SERVER_VERSION ,
2217 cleanStackTrace ,
2318 cleanOptionalStackTrace ,
2419 compareStackTrace ,
2520 getRandomPort ,
2621 ByteSkewerPayloadCodec ,
2722 test ,
28- testTimeSkipping ,
23+ noopTest ,
2924 Worker ,
3025 TestWorkflowEnvironment ,
31- baseBundlerIgnoreModules ,
26+ } from '@temporalio/test-helpers' ;
27+ import {
28+ createBaseBundlerOptions ,
29+ loadHistory as loadHistoryBase ,
30+ saveHistory as saveHistoryBase ,
3231} from '@temporalio/test-helpers' ;
3332
3433/**
3534 * Package-specific bundler options that include local activity and mock-native-worker modules.
3635 */
37- export const bundlerOptions = {
38- // This is a bit ugly but it does the trick, when a test that includes workflow code tries to import a forbidden
39- // workflow module, add it to this list:
40- ignoreModules : [
41- '@temporalio/common/lib/internal-non-workflow' ,
42- '@temporalio/activity' ,
43- '@temporalio/client' ,
44- '@temporalio/testing' ,
45- '@temporalio/nexus' ,
46- '@temporalio/worker' ,
47- 'ava' ,
48- 'crypto' ,
49- 'module' ,
50- 'path' ,
51- 'stack-utils' ,
52- '@grpc/grpc-js' ,
53- 'async-retry' ,
54- 'uuid' ,
55- 'net' ,
56- 'fs/promises' ,
57- 'timers' ,
58- 'timers/promises' ,
59- require . resolve ( './activities' ) ,
60- require . resolve ( './mock-native-worker' ) ,
61- ] ,
62- } ;
36+ export const bundlerOptions = createBaseBundlerOptions ( [
37+ require . resolve ( './activities' ) ,
38+ require . resolve ( './mock-native-worker' ) ,
39+ ] ) ;
6340
6441// Some of our tests expect "default custom search attributes" to exists, which used to be the case
6542// in all deployment with support for advanced visibility. However, this might no longer be true in
@@ -119,24 +96,16 @@ export async function registerDefaultCustomSearchAttributes(connection: Connecti
11996
12097/**
12198 * Load a history file from the history_files directory.
122- * This is kept here for backward compatibility with existing tests.
12399 */
124100export async function loadHistory ( fname : string ) : Promise < iface . temporal . api . history . v1 . History > {
125- const isJson = fname . endsWith ( 'json' ) ;
126101 const fpath = path . resolve ( __dirname , `../history_files/${ fname } ` ) ;
127- if ( isJson ) {
128- const hist = await fs . readFile ( fpath , 'utf8' ) ;
129- return JSON . parse ( hist ) ;
130- } else {
131- const hist = await fs . readFile ( fpath ) ;
132- return iface . temporal . api . history . v1 . History . decode ( hist ) ;
133- }
102+ return loadHistoryBase ( fpath ) ;
134103}
135104
136105/**
137106 * Save a history file to the history_files directory.
138107 */
139108export async function saveHistory ( fname : string , history : iface . temporal . api . history . v1 . IHistory ) : Promise < void > {
140109 const fpath = path . resolve ( __dirname , `../history_files/${ fname } ` ) ;
141- await fs . writeFile ( fpath , historyToJSON ( history ) ) ;
110+ return saveHistoryBase ( fpath , history ) ;
142111}
0 commit comments