Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Thinkmill/jest-fixtures
Use file system fixtures in Jest
https://github.com/Thinkmill/jest-fixtures
fixtures jest test
Last synced: 3 months ago
JSON representation
Use file system fixtures in Jest
- Host: GitHub
- URL: https://github.com/Thinkmill/jest-fixtures
- Owner: Thinkmill
- License: mit
- Created: 2017-09-04T06:03:50.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-04-03T00:15:48.000Z (almost 7 years ago)
- Last Synced: 2024-07-26T13:37:48.957Z (6 months ago)
- Topics: fixtures, jest, test
- Language: JavaScript
- Size: 114 KB
- Stars: 39
- Watchers: 25
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# jest-fixtures
> [WIP]
## Installation
```sh
yarn add --dev jest-fixtures
```## API
##### `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();
});
```