Skip to main content
Version: Next

createVersionedContextForTesting()

Home > @backstage/version-bridge > createVersionedContextForTesting

Creates a helper for writing tests towards multiple different combinations of versions provided from a context.

Signature:

function createVersionedContextForTesting(key: string): {
set(versions: {
[x: number]: unknown;
}): void;
reset(): void;
};

Parameters

Parameter

Type

Description

key

string

A key that uniquely identifies the context.

**Returns:**

{ set(versions: { [x: number]: unknown; }): void; reset(): void; }

Example

const context = createVersionedContextForTesting('my-context');

afterEach(() => {
context.reset();
});

it('should work when provided with version 1', () => {
context.set({1: 'value-for-version-1'})

// ...
})