Skip to main content

MockDirectory.content()

Home > @backstage/backend-test-utils > MockDirectory > content

Reads the content of the mock directory.

Signature:

content(options?: MockDirectoryContentOptions): MockDirectoryContent | undefined;

Parameters

ParameterTypeDescription
optionsMockDirectoryContentOptions(Optional)

Returns:

MockDirectoryContent | undefined

Remarks

Text files will be returned as strings, while binary files will be returned as buffers. By default the file extension is used to determine whether a file should be read as text.

Example

expect(mockDir.content()).toEqual({
'test.txt': 'content',
'sub-dir': {
'file.txt': 'content',
'nested-dir': {
'file.txt': 'content',
},
},
'empty-dir': {},
'binary-file': Buffer.from([0, 1, 2]),
});