Lightweight testing framework for use with @K-FOSS/TS-ESNode
@k-foss/ts-estests" alt="Libraries.io dependency status for latest release, scoped npm package">
@K-FOSS/TS-ESTests is a lightweight testing framework for use with ESNext & ESModules code. Orignally created within my @K-FOSS/TS-ESNode repo for testing.
This is an ESModule and requires Node.JS 13.9 or newer
Install the module
npm install @k-foss/ts-estests
Test Suite [Tests/Add.test.ts
]
// Tests/AddTest/add.test.ts
import { TestSuite } from '@k-foss/ts-estests';
import { strictEqual } from 'assert';
import { add } from '../src/Add';
export class AddTest extends TestSuite {
public testName = 'addTest';
public async test(): Promise<void> {
strictEqual(add(1, 1), 2, 'add(1, 1) === 2');
strictEqual(add(1, 2), 3, 'add(1, 2) === 3');
strictEqual(add(5, 5), 10, 'add(5, 5) === 10');
}
}
Source file your testing src/Add.ts
// src/Add.ts
export function add(a: number, b: number): number {
return a + b;
}
Example package.json
{
"type": "module",
"scripts": {
"test": "ts-estest ./Tests"
}
}
Follow these steps to open this project in a container:
If this is your first time using a development container, please follow the getting started steps.
To use this repository, you can either open the repository in an isolated Docker volume:
K-FOSS/TS-ESTests
Or open a locally cloned copy of the code:
git clone https://github.com/K-FOSS/TS-ESTests.git
code ./TS-ESTests
Reopen in Container
Or manually reopen
TBD
MUST HAVE NODE.JS v13.9 or newer
To try this out, clone repo
Install NPM modules
npm install
Run all tests under ./Testing/Tests/
npm test
All tests are run on all commits and PRs.
This project currently uses Prettier for code styling and automatic formatting. Prettier is run on every commit and pull request.
Run Prettier
npm run prettier
This project currently uses ESLint for code linting. ESLint is run on every commits and pull request.
Run ESLint
npm run lint
Dependency Management for TS-ESTests is handled by automated pull requests created by Dependabot. When new released of development Dependencies are released Dependabot automatically creates a pull request for upgrading to the new version. If the created pull request passes the GitHub Actions testing, prettier/styling, and linting I will merge the pull request.
@K-FOSS/TS-ESTests uses semantic-release to intelligently automate the creation of a changelog, automatic package publish to NPM, along with creating a GitHub release and tag.
Semantic-Release is currently configured to analyze commits with the Conventional Commits preset to determine if and how the package version should be incremented and if a release should be published, which is why it is important to mantain the Conventional Commits spec for all commits.