Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/targendaz2/jest-extended-fs
Adds file system matchers to Jest.
https://github.com/targendaz2/jest-extended-fs
assert assertions files filesystem jest test testing
Last synced: 2 months ago
JSON representation
Adds file system matchers to Jest.
- Host: GitHub
- URL: https://github.com/targendaz2/jest-extended-fs
- Owner: targendaz2
- License: mit
- Created: 2024-06-16T22:20:27.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2024-07-06T02:38:52.000Z (7 months ago)
- Last Synced: 2024-10-06T21:17:26.615Z (4 months ago)
- Topics: assert, assertions, files, filesystem, jest, test, testing
- Language: TypeScript
- Homepage:
- Size: 216 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# jest-extended-fs
![GitHub License](https://img.shields.io/github/license/targendaz2/jest-extended-fs)
![GitHub Release](https://img.shields.io/github/v/release/targendaz2/jest-extended-fs?label=version)
![NPM Version](https://img.shields.io/npm/v/jest-extended-fs?logo=npm&logoColor=%23999999)
![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/targendaz2/jest-extended-fs/test.yml?logo=github&label=tests&logoColor=%23999999)This package adds file system matchers to [Jest](https://jestjs.io).
## Installation
This package is available on npm as [`jest-extended-fs`](https://npmjs.com/package/jest-extended-fs).
```bash
npm install -D jest jest-extended-fs
```## Set Up
### Individual Matchers
In your Jest configuration file (e.g. `jest.config.ts`), for each matcher you want to enable, add the matcher to the [`setupFilesAfterEnv`](setupFilesAfterEnv) setting.
```TypeScript
const config = {
setupFilesAfterEnv = ['jest-extended-fs/matchers/toBeAFile.js']
};
```### All Matchers
Follow the "Individual Matchers" instructions above using `jest-extended-fs` instead of any specific matcher.
```TypeScript
const config = {
setupFilesAfterEnv = ['jest-extended-fs']
};
```## Matchers
### Common Matchers
- `.toExist()`
### Directory Matchers
- `.toBeADirectory()`
- `.toBeADirectoryContaining(contents)`
- `.toBeAnEmptyDirectory()`### File Matchers
- `.toBeAFile()`
- `.toBeAFileContaining(text)`
- `.toBeAnEmptyFile()`
- `.toHaveMode(mode)`
- `.toBeExecutable()`## Contributing
Pull requests are welcome. For major changes, please open an issue first
to discuss what you would like to change.Please make sure to update tests as appropriate.
## License
This package is licensed under the [MIT License](https://github.com/targendaz2/jest-extended-fs/blob/main/LICENSE).