Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/luuuis/mokapot
DRY, reusable and composable test resources for Mocha.
https://github.com/luuuis/mokapot
fixture jest mocha
Last synced: 20 days ago
JSON representation
DRY, reusable and composable test resources for Mocha.
- Host: GitHub
- URL: https://github.com/luuuis/mokapot
- Owner: luuuis
- Created: 2021-01-25T18:34:31.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2021-02-15T15:57:55.000Z (over 3 years ago)
- Last Synced: 2024-10-12T14:34:03.981Z (about 1 month ago)
- Topics: fixture, jest, mocha
- Language: TypeScript
- Homepage:
- Size: 50.8 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# mokapot.js
![](https://raw.githubusercontent.com/luuuis/mokapot/master/assets/noun_Moka%20Pot_101129.png)
DRY, reusable and composable test resources for Mocha.
```ecmascript 6
import { mokapot} from 'mokapot'// pair of Promise-returning functions
const createServer = (dir) => mokapot.async(
async () => createServerAsync({ workDir: dir() }), // set up
async (server) => server.closeAsync() // optional tear down
)// async generator
const createServerGen = (dir) => mokapot.gen(async function* () {
const server = await createServerAsync({ workDir: dir() })
yield server
await server.closeAsync()
})// pair of sync functions
const tmpDir = mokapot.sync(
() => fs.mkdirSync('/tmp/' + Math.random),
(dir) => fs.rmdirSync(dir)
)// pair of NodeJS-style functions
const anotherTmpDir = mokapot.node(
(cb) => fs.mkdir('/tmp/' + Math.random, cb),
(dir, cb) => fs.rmdir(dir, cb)
)describe('server test', function () {
const tmp = mokapot.before(tmpDir)
const server = mokapot.beforeEach(createServer(tmp))it('should respond', function () {
assert(server() instanceof Server) // get current value
});
});
```Moka Pot icon created by Marvin Wilhelm for the Noun Project