A Complex Case
Imagine these steps to perform a test:
- Perform Unit Tests suite in parallel
- Clear and Populate the Database
- Check for Expected Successes Integration suite sequentially
- Clear and Populate the Database β again
- Check for Expected Failures Integration suite sequentially
Requirements:
Each step requires success to be processed.
Directory Structure:
βββ .
βββ test
β βββ unit
β βββ integration
β β βββ successes
β β β βββ **/.spec.js
β β βββ failures
β β βββ **/.spec.js
β ββ run.test.js # The runner
β ββ tools.test.js
Do we really need to complicate things even more by creating advanced tests runs to run our already complex tests? π
Poku's Solution β¨β
import { poku, assert } from 'poku';
import { recreateDatabase } from './tools.test.js';
const unitCode = await poku('test/unit', {
parallel: true,
noExit: true,
});
assert.strictEqual(0, unitCode, 'Running Unit Tests');
await assert.doesNotReject(
recreateDatabase(),
'Preparing DB for Successes Integration Tests'
);
const successesCode = await poku('test/integration/successes', {
noExit: true,
});
assert.strictEqual(0, successesCode, 'Running Successes Integration Tests');
await assert.doesNotReject(
recreateDatabase(),
'Preparing DB for Successes Integration Tests'
);
const failuresCode = await poku('test/integration/failures', {
noExit: true,
});
assert.strictEqual(0, failuresCode, 'Running Failures Integration Tests');
Why comment the code if we can do it better? π§π»
Finally
npx poku test/run.test.js
Or
npx poku test/run.test.ts
for TypeScript.