0.6.0 • Published 7 years ago

jest-fixtures v0.6.0

Weekly downloads
2,088
License
MIT
Repository
github
Last release
7 years ago

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();
});