tdd-buffet v4.0.0
All you can eat TDD tools and libraries
Install
npm install tdd-buffetTesting
This package exposes a wrapper over Jest that provides the same building blocks for writing tests (describe and it) and also provides the same CLI.
Create a Node test
Ideally you should have many of these since they're fast to run. They execute in a jsdom environment so you can test both your Node libraries and your React components. Since they're fast, you should use them to check your code's correctness and achieve satisfactory coverage.
import { describe, it } from 'tdd-buffet/suite/node';
import { expect } from 'tdd-buffet/suite/chai';
describe('Node suite', () => {
it('should run a test', () => {
expect(1).to.equal(1);
});
});Create a GUI test
These tests will spin up Puppeteer in headless mode and pass the page instance in the test callback. The browser and page will be set up once per test suite and persisted between individual tests.
These tests are slower than Node tests. Therefore, you should not rely on them to exhaustively check the correctness of your code. You can start with them to have some basic coverage, but try to make your down to smaller, faster, more focused tests.
import { describe, it } from 'tdd-buffet/suite/gui';
describe('Gui suite', () => {
it('should run a test', async (page) => {
await page.goto('http://github.com');
});
});Assertions
You can choose between jest's builtin assertions or chai's assertions.
import { describe, it } from 'tdd-buffet/suite/node';
import { expect as chaiExpect } from 'tdd-buffet/expect/chai';
import { expect as jestExpect } from 'tdd-buffet/expect/jest';
describe('Expect', () => {
describe('chai', () => {
it('should compare things', () => {
chaiExpect(1).to.equal(1);
chaiExpect({ foo: 'bar' }).to.deep.equal({ foo: 'bar' });
});
});
describe('jest', () => {
it('should compare things', () => {
jestExpect(1).toEqual(1);
jestExpect({ foo: 'bar' }).toEqual({ foo: 'bar' });
});
});
});Run the tests
npx tdd-buffet testThis will run all the tests matched by the default Jest config. You can pass your own config through the --config option. The command accepts all Jest arguments:
npx tdd-buffet test --runInBand tests/my-test.spec.tsxCoverage
You can pass the --coverage option to generate coverage with the options specified in the Jest config.
You can control how coverage is collected (output folder, thresholds etc.) through Jest's coverage options.
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago