diff --git a/README.md b/README.md index 366d16e..c89556a 100644 --- a/README.md +++ b/README.md @@ -65,6 +65,15 @@ The unit tests can be run with the following command: pnpm test ``` +To get test coverage + +```shell +# Does not work via pnpm script so need to call node directly +node --import tsx --test --experimental-test-coverage --test-reporter=lcov --test-reporter-destination=lcov.info src/*.test.ts +# To generate a html report use genhtml which is part of lcov OS package +genhtml lcov.info --output-directory coverage +``` + The end-to-end tests are written with [playwright](https://playwright.dev/). The tests are in `apps/class-solid/tests/*.spec.ts` and can be run with the following command: diff --git a/packages/class/.gitignore b/packages/class/.gitignore new file mode 100644 index 0000000..bfefed5 --- /dev/null +++ b/packages/class/.gitignore @@ -0,0 +1,2 @@ +lcov.info +coverage/ diff --git a/packages/class/package.json b/packages/class/package.json index 0b6b922..ebf12a3 100644 --- a/packages/class/package.json +++ b/packages/class/package.json @@ -22,6 +22,6 @@ "zod-to-json-schema": "^3.23.1" }, "engines": { - "node": ">=20" + "node": ">=20.16.0" } } diff --git a/packages/class/src/bmi.test.ts b/packages/class/src/bmi.test.ts new file mode 100644 index 0000000..52f1e7c --- /dev/null +++ b/packages/class/src/bmi.test.ts @@ -0,0 +1,19 @@ +import assert from "node:assert/strict"; +import { before, describe, test } from "node:test"; +import { BmiClass } from "./bmi"; + +describe("BmiClass", () => { + let bmi: BmiClass; + before(() => { + bmi = new BmiClass(); + }); + + describe("get_component_name", () => { + test("returns the component name", () => { + assert.strictEqual( + bmi.get_component_name(), + "Chemistry Land-surface Atmosphere Soil Slab model", + ); + }); + }); +});