Skip to content

Latest commit

 

History

History
104 lines (58 loc) · 2.12 KB

README.md

File metadata and controls

104 lines (58 loc) · 2.12 KB

@wasm-codecs/test-utils

Test utility functions for other @wasm-codecs packages

Table of contents

  1. Installation
  2. Usage
  3. API
  4. License

Installation

This is a private and unpublished package and can not be installed from the npm registry.

To add @wasm-codecs/test-utils to a new package within this repository, run the following command in the root directory of this monorepo:

npm run lerna add @wasm-codecs/test-utils -- --scope=@wasm-codecs/TARGET-CODEC-NAME

Usage

import { initTestUtils, cleanup } from '@wasm-codecs/test-utils';

describe('my test', () => {
  beforeAll(() => {
    initTestUtils(__dirname);
  );

  afterAll(cleanup);

  // ...
});

API

initTestUtils(basePath): void

Initializes the test utils by configuring internal paths.

basePath: string

Path to the test root.

cleanup(force?): void

Cleans up tests by removing temporary files and directories.

force?: boolean

If true, will forcefully remove the tmp directory, even if the KEEP_IMAGE_OUTPUT env variable is set.

async getImage(fileName): { data: Buffer; info: OutputInfo }

Loads an image file and returns its buffer and information.

fileName: string

Name of the image file to load.

async getRawImage(fileName: string): { data: Buffer; info: OutputInfo }

Loads an image file and returns its raw RGB data per pixel and information.

fileName: string

Name of the image file to load.

async getImageMetadata(fileName): Metadata

Returns all available metadata of an image.

fileName: string

Name of the image file to load.

getFileSize(fileName: string): number

Returns the size of a file in bytes.

fileName: string

Name of the image file to load.

writeTmpBuffer(data: Buffer, fileName: string): number

Writes a buffer into a temporary file.

data: Buffer

Buffer to write.

fileName: string

Filename of the temporary file.

License

Licensed under the MIT license.

© Copyright Cyril Wanner