Socket
Socket
Sign inDemoInstall

@ms-cloudpack/test-utilities

Package Overview
Dependencies
2
Maintainers
3
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @ms-cloudpack/test-utilities

Common test utilities for the Cloudpack repo.


Version published
Weekly downloads
14
increased by55.56%
Maintainers
3
Install size
97.0 kB
Created
Weekly downloads
 

Readme

Source

@ms-cloudpack/test-utilities

Utilities for testing libraries within the Cloudpack repo.

APIs

createTempDir(options)

Creates a temporary directory and returns the normalized path.

This directory should be deleted automatically when the program exits, but it's more reliable to include manual cleanup in your code.

Options:

  • prefix?: string: Prefix for the temp directory (a random suffix will be added). Default is cloudpack-test-.

Example:

import { createTempDir } from '@ms-cloudpack/test-utilities';

const testFolder = createTempDir({
  prefix: 'some-prefix-', // default is 'cloudpack-test-'
});

createTestFileStructure(files, options)

Creates a test folder and populates it with content. For each key in files, create a test folder and write a file of that filename, where the content is the value.

Returns the path to the test folder.

Parameters:

  • files: Record<string, string | Record<string, unknown>>: Mapping from file path to contents. String contents will be written as-is; objects will be written with JSON.stringify.
  • options object (optional):
    • testName?: string: Test name to use in the temp directory name (cloudpack-test-<testName>-).
    • parentDir?: string: Absolute path to a parent directory for the test file structure (will be created if needed), to be used instead of creating a random temporary directory.
    • links?: Record<string, string>: Create these links in the temp directory. Keys are link paths and values are source paths (both relative).

Example:

import { createTestFileStructure } from '@ms-cloudpack/test-utilities';

const testFolder = await createTestFileStructure({
  './package.json': { name: 'asdf' },
  './src/bar.ts': "export default 'hi';",
});

console.log(readJson(path.join(testFolder, 'package.json')));

FAQs

Last updated on 02 Feb 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc