Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/paulmillr/micro-should
Simplest zero-dependency testing framework, a drop-in replacement for Mocha.
https://github.com/paulmillr/micro-should
bdd framework it jasmine jest karma micro mocha should tdd test testing
Last synced: 3 months ago
JSON representation
Simplest zero-dependency testing framework, a drop-in replacement for Mocha.
- Host: GitHub
- URL: https://github.com/paulmillr/micro-should
- Owner: paulmillr
- License: mit
- Created: 2019-08-05T09:19:51.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-02-04T09:53:19.000Z (almost 2 years ago)
- Last Synced: 2024-05-08T17:03:00.068Z (8 months ago)
- Topics: bdd, framework, it, jasmine, jest, karma, micro, mocha, should, tdd, test, testing
- Language: JavaScript
- Homepage:
- Size: 773 KB
- Stars: 16
- Watchers: 3
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# micro-should
Simplest zero-dependency testing framework, a drop-in replacement for Mocha.
Supports async cases. Works with any assertion library.
* `should(title, case)` (or `it(title, case)`) syntax
* `should.only(title, case)` allows to limit tests to only one case
* `should.skip(title, case)` allows to skip functions instead of commenting them out
* `describe(prefix, cases)` for nested execution
* `should.run()` must always be executed in the end
* `should.runParallel()` for CPU-intensive tasks, would ramp up threads equal to CPU count> npm install micro-should
![](https://raw.githubusercontent.com/paulmillr/micro-should/e60028e947f3158c46314ef105b51b2a2948c025/screenshot.png)
## Usage
```js
const { should } = require('micro-should');
const assert = require('assert'); // You can use any assertion library (e.g. Chai or Expect.js), example uses built-in nodejsshould('add two numbers together', () => {
assert.equal(2 + 2, 4);
});should('catch errors', () => {
assert.throws(() => {
throw new Error('invalid');
});
});should('produce correct promise result', async () => {
const fs = require('fs').promises;
const data = await fs.readFile('README.md', 'utf-8');
assert.ok(data.includes('Minimal testing'));
});// should.only("execute only one test", () => {
// assert.ok(true);
// });// should.skip("disable one test by using skip", () => {
// assert.ok(false); // would not execute
// })// Nested
const { describe } = require('micro-should');
describe('during any time of day', () => {
describe('without hesitation', () => {
should('multiply two numbers together', () => {
assert.equal(2 * 2, 4);
});should('multiply three numbers together', () => {
assert.equal(3 * 3 * 3, 27);
});
});
});// Execute this at the end of a file.
should.run();
```## License
MIT (c) Paul Miller (https://paulmillr.com), see LICENSE file.