[WIP]
yarn add --dev jest-fixtures
import {getFixturePath} from 'jest-fixtures';
test('example', async () => {
let fixturePath = await getFixturePath(__dirname, 'fixture-name');
let fixtureFilePath = await getFixturePath(__dirname, 'fixture-name', 'file.txt');
// ...
});
import {getFixturePathSync} from 'jest-fixtures';
test('example', () => {
let fixturePath = getFixturePathSync(__dirname, 'fixture-name');
let fixtureFilePath = getFixturePathSync(__dirname, 'fixture-name', 'file.txt');
// ...
});
import {createTempDir} from 'jest-fixtures';
test('example', async () => {
let tempDirPath = await createTempDir();
// ...
});
import {createTempDirSync} from 'jest-fixtures';
test('example', () => {
let tempDirPath = createTempDirSync();
// ...
});
import {copyDir} from 'jest-fixtures';
test('example', async () => {
await copyDir('/path/to/source/dir', '/path/to/dest/dir');
// ...
});
import {copyDirIntoTempDir} from 'jest-fixtures';
test('example', async () => {
let tempDir = await copyDirIntoTempDir('/path/to/source/dir');
// ...
});
import {copyFixtureIntoTempDir} from 'jest-fixtures';
test('example', async () => {
let tempDir = await copyFixtureIntoTempDir(__dirname, 'fixture-name');
// ...
});
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();
});