@fluidframework/test-utils Package
Interfaces
Interface | Description |
---|---|
IOpProcessingController | |
IProvideTestFluidObject | |
ITestContainerConfig | |
ITestFluidObject | |
ITestObjectProvider | |
TimeoutWithError | |
TimeoutWithValue |
Classes
Class | Description |
---|---|
EventAndErrorTrackingLogger | This class tracks events. It allows specifying expected events, which will be looked for in order. It also tracks all unexpected errors. At any point you call reportAndClearTrackedEvents which will provide all unexpected errors, and any expected events that have not occurred. |
LoaderContainerTracker | |
LocalCodeLoader | A simple code loader that caches a mapping of package name to a Fluid entry point. On load, it retrieves the entry point matching the package name in the given code details. |
TestFluidObject | A test Fluid object that will create a shared object for each key-value pair in the factoryEntries passed to load. The shared objects can be retrieved by passing the key of the entry to getSharedObject. It exposes the IFluidDataStoreContext and IFluidDataStoreRuntime. |
TestFluidObjectFactory |
Creates a factory for a TestFluidObject with the given object factory entries. It creates a data store runtime with the object factories in the entry list. All the entries with an id other than undefined are passed to the Fluid object so that it can create a shared object for each. For example, the following will create a Fluid object that creates and loads a SharedString and SharedDirectory. It will add SparseMatrix to the data store's factory so that it can be created later. new TestFluidObjectFactory([ [ "sharedString", SharedString.getFactory() ], [ "sharedDirectory", SharedDirectory.getFactory() ], [ undefined, SparseMatrix.getFactory() ], ]); The SharedString and SharedDirectory can be retrieved via getSharedObject() on the TestFluidObject as follows: sharedString = testFluidObject.getSharedObject("sharedString"); sharedDir = testFluidObject.getSharedObject("sharedDirectory"); |
TestObjectProvider | Shared base class for test object provider. Contain code for loader and container creation and loading |
Enumerations
Enum | Description |
---|---|
DataObjectFactoryType |
Types
TypeAlias | Description |
---|---|
ChannelFactoryRegistry | |
fluidEntryPoint | |
SupportedExportInterfaces |
Functions
Function | Return Type | Description |
---|---|---|
createAndAttachContainer(source, loader, attachRequest) | Promise<IContainer> | Creates a detached Container and attaches it. |
createLoader(packageEntries, documentServiceFactory, urlResolver, logger, options) | IHostLoader | Creates a loader with the given package entries and driver. |
createSummarizer(provider, container, summaryVersion, gcOptions) | Promise<ISummarizer> | |
createSummarizerFromFactory(provider, container, dataStoreFactory, summaryVersion, containerRuntimeFactoryType) | Promise<ISummarizer> | |
getUnexpectedLogErrorException(logger, prefix) | Error | undefined | |
summarizeNow(summarizer, reason) | Promise<{ summaryTree: import("@fluidframework/protocol-definitions").ISummaryTree; summaryVersion: string; }> | |
timeoutAwait(promise, timeoutOptions) | Promise<T> | |
timeoutPromise(executor, timeoutOptions) | Promise<T> | |
waitForContainerConnection(container) | Promise<void> | |
wrapDocumentService(innerDocService, uploadSummaryCb) | IDocumentService | Wraps the given IDocumentService to override the connectToStorage method. The intent is to plumb the uploadSummaryCb to the IDocumentStorageService so that it is called whenever a summary is uploaded by the client. The document storage service that is created in connectToStorage is wrapped by calling wrapDocumentStorageService to pass in the uploadSummaryCb . |
wrapDocumentServiceFactory(innerDocServiceFactory, uploadSummaryCb) | IDocumentServiceFactory | Wraps the given IDocumentServiceFactory to override the createDocumentService method. The intent is to plumb the uploadSummaryCb all the way to the IDocumentStorageService so that it is called whenever a summary is uploaded by the client. The document service that is created in createDocumentService is wrapped by calling wrapDocumentService to pass in the uploadSummaryCb . |
wrapDocumentStorageService(innerDocStorageService, uploadSummaryCb) | IDocumentStorageService | Wraps the given IDocumentStorageService to override the uploadSummaryWithContext method. It calls the uploadSummaryCb whenever a summary is uploaded by the client. The summary context can be updated in the callback before it is uploaded to the server. |
Variables
Variable | Type | Description |
---|---|---|
createDocumentId | () => string | |
createTestContainerRuntimeFactory | (containerRuntimeCtor: typeof ContainerRuntime) => { new (type: string, dataStoreFactory: IFluidDataStoreFactory, runtimeOptions?: IContainerRuntimeOptions, requestHandlers?: RuntimeRequestHandler[]): { type: string; dataStoreFactory: IFluidDataStoreFactory; runtimeOptions: IContainerRuntimeOptions; requestHandlers: RuntimeRequestHandler[]; instantiateFirstTime(runtime: ContainerRuntime): Promise<void>; instantiateFromExisting(runtime: ContainerRuntime): Promise<void>; preInitialize(context: IContainerContext, existing: boolean): Promise<IRuntime & IContainerRuntime>; readonly IRuntimeFactory: any; instantiateRuntime(context: IContainerContext, existing?: boolean | undefined): Promise<IRuntime>; hasInitialized(_runtime: IContainerRuntime): Promise<void>; }; } | Create a container runtime factory class that allows you to set runtime options |
defaultTimeoutDurationMs | ||
mockConfigProvider | (settings?: Record<string, ConfigTypes>) => IConfigProviderBase | |
retryWithEventualValue | <T>(callback: () => Promise<T>, check: (value: T) => boolean, defaultValue: T, maxTries?: number, backOffMs?: number) => Promise<T> | Simple retry mechanism with linear back off to call a function which may eventually return an accepted value. |
TestContainerRuntimeFactory | { new (type: string, dataStoreFactory: IFluidDataStoreFactory, runtimeOptions?: IContainerRuntimeOptions, requestHandlers?: RuntimeRequestHandler[]): { type: string; dataStoreFactory: IFluidDataStoreFactory; runtimeOptions: IContainerRuntimeOptions; requestHandlers: RuntimeRequestHandler[]; instantiateFirstTime(runtime: ContainerRuntime): Promise<void>; instantiateFromExisting(runtime: ContainerRuntime): Promise<void>; preInitialize(context: IContainerContext, existing: boolean): Promise<IRuntime & IContainerRuntime>; readonly IRuntimeFactory: any; instantiateRuntime(context: IContainerContext, existing?: boolean | undefined): Promise<IRuntime>; hasInitialized(_runtime: IContainerRuntime): Promise<void>; }; } | A container runtime factory that allows you to set runtime options |
Function Details
createAndAttachContainer
Creates a detached Container and attaches it.
Signature
export declare function createAndAttachContainer(source: IFluidCodeDetails, loader: IHostLoader, attachRequest: IRequest): Promise<IContainer>;
Parameters
Parameter | Type | Description |
---|---|---|
source | IFluidCodeDetails | The code details used to create the Container. |
loader | IHostLoader | The loader to use to initialize the container. |
attachRequest | IRequest | The request to create new from. |
Returns
Return type: Promise<IContainer>
createLoader
Creates a loader with the given package entries and driver.
Signature
export declare function createLoader(packageEntries: Iterable<[IFluidCodeDetails, fluidEntryPoint]>, documentServiceFactory: IDocumentServiceFactory, urlResolver: IUrlResolver, logger?: ITelemetryBaseLogger, options?: ILoaderOptions): IHostLoader;
Parameters
Parameter | Modifiers | Type | Description |
---|---|---|---|
packageEntries | Iterable<[IFluidCodeDetails, fluidEntryPoint]> | A list of code details to Fluid entry points. | |
documentServiceFactory | IDocumentServiceFactory | the driver factory to use | |
urlResolver | IUrlResolver | the url resolver to use | |
logger | optional | ITelemetryBaseLogger | |
options | optional | ILoaderOptions | loader options |
Returns
Return type: IHostLoader
createSummarizer
Signature
export declare function createSummarizer(provider: ITestObjectProvider, container: IContainer, summaryVersion?: string, gcOptions?: IGCRuntimeOptions): Promise<ISummarizer>;
Parameters
Parameter | Modifiers | Type | Description |
---|---|---|---|
provider | ITestObjectProvider | ||
container | IContainer | ||
summaryVersion | optional | string | |
gcOptions | optional | IGCRuntimeOptions |
Returns
Return type: Promise<ISummarizer>
createSummarizerFromFactory
Signature
export declare function createSummarizerFromFactory(provider: ITestObjectProvider, container: IContainer, dataStoreFactory: IFluidDataStoreFactory, summaryVersion?: string, containerRuntimeFactoryType?: typeof ContainerRuntimeFactoryWithDefaultDataStore): Promise<ISummarizer>;
Parameters
Parameter | Modifiers | Type | Description |
---|---|---|---|
provider | ITestObjectProvider | ||
container | IContainer | ||
dataStoreFactory | IFluidDataStoreFactory | ||
summaryVersion | optional | string | |
containerRuntimeFactoryType | optional | typeof ContainerRuntimeFactoryWithDefaultDataStore |
Returns
Return type: Promise<ISummarizer>
getUnexpectedLogErrorException
Signature
export declare function getUnexpectedLogErrorException(logger: EventAndErrorTrackingLogger | undefined, prefix?: string): Error | undefined;
Parameters
Parameter | Modifiers | Type | Description |
---|---|---|---|
logger | EventAndErrorTrackingLogger | undefined | ||
prefix | optional | string |
Returns
Return type: Error | undefined
summarizeNow
Signature
export declare function summarizeNow(summarizer: ISummarizer, reason?: string): Promise<{
summaryTree: import("@fluidframework/protocol-definitions").ISummaryTree;
summaryVersion: string;
}>;
Parameters
Parameter | Modifiers | Type | Description |
---|---|---|---|
summarizer | ISummarizer | ||
reason | optional | string |
Returns
Return type: Promise<{ summaryTree: import("@fluidframework/protocol-definitions").ISummaryTree; summaryVersion: string; }>
timeoutAwait
Signature
export declare function timeoutAwait<T = void>(promise: PromiseLike<T>, timeoutOptions?: TimeoutWithError | TimeoutWithValue<T>): Promise<T>;
Type Parameters
Parameter | Default | Description |
---|---|---|
T | void |
Parameters
Parameter | Modifiers | Type | Description |
---|---|---|---|
promise | PromiseLike<T> | ||
timeoutOptions | optional | TimeoutWithError | TimeoutWithValue<T> |
Returns
Return type: Promise<T>
timeoutPromise
Signature
export declare function timeoutPromise<T = void>(executor: (resolve: (value: T | PromiseLike<T>) => void, reject: (reason?: any) => void) => void, timeoutOptions?: TimeoutWithError | TimeoutWithValue<T>): Promise<T>;
Type Parameters
Parameter | Default | Description |
---|---|---|
T | void |
Parameters
Parameter | Modifiers | Type | Description |
---|---|---|---|
executor | (resolve: (value: T | PromiseLike<T>) => void, reject: (reason?: any) => void) => void | ||
timeoutOptions | optional | TimeoutWithError | TimeoutWithValue<T> |
Returns
Return type: Promise<T>
waitForContainerConnection
Signature
export declare function waitForContainerConnection(container: IContainer): Promise<void>;
Parameters
Parameter | Type | Description |
---|---|---|
container | IContainer |
Returns
Return type: Promise<void>
wrapDocumentService
Wraps the given IDocumentService to override the connectToStorage
method. The intent is to plumb the uploadSummaryCb
to the IDocumentStorageService so that it is called whenever a summary is uploaded by the client. The document storage service that is created in connectToStorage
is wrapped by calling wrapDocumentStorageService
to pass in the uploadSummaryCb
.
Signature
export declare function wrapDocumentService(innerDocService: IDocumentService, uploadSummaryCb: (summaryTree: ISummaryTree, context: ISummaryContext) => ISummaryContext): IDocumentService;
Parameters
Parameter | Type | Description |
---|---|---|
innerDocService | IDocumentService | |
uploadSummaryCb | (summaryTree: ISummaryTree, context: ISummaryContext) => ISummaryContext |
Returns
Return type: IDocumentService
wrapDocumentServiceFactory
Wraps the given IDocumentServiceFactory to override the createDocumentService
method. The intent is to plumb the uploadSummaryCb
all the way to the IDocumentStorageService so that it is called whenever a summary is uploaded by the client. The document service that is created in createDocumentService
is wrapped by calling wrapDocumentService
to pass in the uploadSummaryCb
.
Signature
export declare function wrapDocumentServiceFactory(innerDocServiceFactory: IDocumentServiceFactory, uploadSummaryCb: (summaryTree: ISummaryTree, context: ISummaryContext) => ISummaryContext): IDocumentServiceFactory;
Parameters
Parameter | Type | Description |
---|---|---|
innerDocServiceFactory | IDocumentServiceFactory | |
uploadSummaryCb | (summaryTree: ISummaryTree, context: ISummaryContext) => ISummaryContext |
Returns
Return type: IDocumentServiceFactory
wrapDocumentStorageService
Wraps the given IDocumentStorageService to override the uploadSummaryWithContext
method. It calls the uploadSummaryCb
whenever a summary is uploaded by the client. The summary context can be updated in the callback before it is uploaded to the server.
Signature
export declare function wrapDocumentStorageService(innerDocStorageService: IDocumentStorageService, uploadSummaryCb: (summaryTree: ISummaryTree, context: ISummaryContext) => ISummaryContext): IDocumentStorageService;
Parameters
Parameter | Type | Description |
---|---|---|
innerDocStorageService | IDocumentStorageService | |
uploadSummaryCb | (summaryTree: ISummaryTree, context: ISummaryContext) => ISummaryContext |
Returns
Return type: IDocumentStorageService
Variable Details
createDocumentId
Signature
createDocumentId: () => string
Type: () => string
createTestContainerRuntimeFactory
Create a container runtime factory class that allows you to set runtime options
Signature
createTestContainerRuntimeFactory: (containerRuntimeCtor: typeof ContainerRuntime) => {
new (type: string, dataStoreFactory: IFluidDataStoreFactory, runtimeOptions?: IContainerRuntimeOptions, requestHandlers?: RuntimeRequestHandler[]): {
type: string;
dataStoreFactory: IFluidDataStoreFactory;
runtimeOptions: IContainerRuntimeOptions;
requestHandlers: RuntimeRequestHandler[];
instantiateFirstTime(runtime: ContainerRuntime): Promise<void>;
instantiateFromExisting(runtime: ContainerRuntime): Promise<void>;
preInitialize(context: IContainerContext, existing: boolean): Promise<IRuntime & IContainerRuntime>;
readonly IRuntimeFactory: any;
instantiateRuntime(context: IContainerContext, existing?: boolean | undefined): Promise<IRuntime>;
hasInitialized(_runtime: IContainerRuntime): Promise<void>;
};
}
Type: (containerRuntimeCtor: typeof ContainerRuntime) => { new (type: string, dataStoreFactory: IFluidDataStoreFactory, runtimeOptions?: IContainerRuntimeOptions, requestHandlers?: RuntimeRequestHandler[]): { type: string; dataStoreFactory: IFluidDataStoreFactory; runtimeOptions: IContainerRuntimeOptions; requestHandlers: RuntimeRequestHandler[]; instantiateFirstTime(runtime: ContainerRuntime): Promise<void>; instantiateFromExisting(runtime: ContainerRuntime): Promise<void>; preInitialize(context: IContainerContext, existing: boolean): Promise<IRuntime & IContainerRuntime>; readonly IRuntimeFactory: any; instantiateRuntime(context: IContainerContext, existing?: boolean | undefined): Promise<IRuntime>; hasInitialized(_runtime: IContainerRuntime): Promise<void>; }; }
defaultTimeoutDurationMs
Signature
defaultTimeoutDurationMs = 250
mockConfigProvider
Signature
mockConfigProvider: (settings?: Record<string, ConfigTypes>) => IConfigProviderBase
Type: (settings?: Record<string, ConfigTypes>) => IConfigProviderBase
retryWithEventualValue
Simple retry mechanism with linear back off to call a function which may eventually return an accepted value.
Signature
retryWithEventualValue: <T>(callback: () => Promise<T>, check: (value: T) => boolean, defaultValue: T, maxTries?: number, backOffMs?: number) => Promise<T>
Type: <T>(callback: () => Promise<T>, check: (value: T) => boolean, defaultValue: T, maxTries?: number, backOffMs?: number) => Promise<T>
TestContainerRuntimeFactory
A container runtime factory that allows you to set runtime options
Signature
TestContainerRuntimeFactory: {
new (type: string, dataStoreFactory: IFluidDataStoreFactory, runtimeOptions?: IContainerRuntimeOptions, requestHandlers?: RuntimeRequestHandler[]): {
type: string;
dataStoreFactory: IFluidDataStoreFactory;
runtimeOptions: IContainerRuntimeOptions;
requestHandlers: RuntimeRequestHandler[];
instantiateFirstTime(runtime: ContainerRuntime): Promise<void>;
instantiateFromExisting(runtime: ContainerRuntime): Promise<void>;
preInitialize(context: IContainerContext, existing: boolean): Promise<IRuntime & IContainerRuntime>;
readonly IRuntimeFactory: any;
instantiateRuntime(context: IContainerContext, existing?: boolean | undefined): Promise<IRuntime>;
hasInitialized(_runtime: IContainerRuntime): Promise<void>;
};
}
Type: { new (type: string, dataStoreFactory: IFluidDataStoreFactory, runtimeOptions?: IContainerRuntimeOptions, requestHandlers?: RuntimeRequestHandler[]): { type: string; dataStoreFactory: IFluidDataStoreFactory; runtimeOptions: IContainerRuntimeOptions; requestHandlers: RuntimeRequestHandler[]; instantiateFirstTime(runtime: ContainerRuntime): Promise<void>; instantiateFromExisting(runtime: ContainerRuntime): Promise<void>; preInitialize(context: IContainerContext, existing: boolean): Promise<IRuntime & IContainerRuntime>; readonly IRuntimeFactory: any; instantiateRuntime(context: IContainerContext, existing?: boolean | undefined): Promise<IRuntime>; hasInitialized(_runtime: IContainerRuntime): Promise<void>; }; }