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