jest-fixtures

0.6.0 • Public • Published

jest-fixtures

[WIP]

Installation

yarn add --dev jest-fixtures

API

getFixturePath(cwd, ...fileParts)
import {getFixturePath} from 'jest-fixtures';
 
test('example', async () => {
  let fixturePath = await getFixturePath(__dirname, 'fixture-name');
  let fixtureFilePath = await getFixturePath(__dirname, 'fixture-name', 'file.txt');
  // ...
});
getFixturePathSync(cwd, ...fileParts)
import {getFixturePathSync} from 'jest-fixtures';
 
test('example', () => {
  let fixturePath = getFixturePathSync(__dirname, 'fixture-name');
  let fixtureFilePath = getFixturePathSync(__dirname, 'fixture-name', 'file.txt');
  // ...
});
createTempDir()
import {createTempDir} from 'jest-fixtures';
 
test('example', async () => {
  let tempDirPath = await createTempDir();
  // ...
});
createTempDirSync()
import {createTempDirSync} from 'jest-fixtures';
 
test('example', () => {
  let tempDirPath = createTempDirSync();
  // ...
});
copyDir()
import {copyDir} from 'jest-fixtures';
 
test('example', async () => {
  await copyDir('/path/to/source/dir', '/path/to/dest/dir');
  // ...
});
copyDirIntoTempDir()
import {copyDirIntoTempDir} from 'jest-fixtures';
 
test('example', async () => {
  let tempDir = await copyDirIntoTempDir('/path/to/source/dir');
  // ...
});
copyFixtureIntoTempDir()
import {copyFixtureIntoTempDir} from 'jest-fixtures';
 
test('example', async () => {
  let tempDir = await copyFixtureIntoTempDir(__dirname, 'fixture-name');
  // ...
});
cleanupTempDirs()

Deletes every temporary directory created by jest-fixtures. This is called automatically when the Jest process exits.

import {createTempDir, cleanupTempDirs} from 'jest-fixtures';
 
test('example', async () => {
  await createTempDir();
  await createTempDir();
  cleanupTempDirs();
});

Readme

Keywords

Package Sidebar

Install

npm i jest-fixtures

Weekly Downloads

1,805

Version

0.6.0

License

MIT

Last publish

Collaborators

  • thejameskyle