Skip to content

Commit

Permalink
More tests + Got working test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
sverhoeven committed Aug 2, 2024
1 parent 777cd71 commit af47564
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 1 deletion.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
2 changes: 2 additions & 0 deletions packages/class/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
lcov.info
coverage/
2 changes: 1 addition & 1 deletion packages/class/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@
"zod-to-json-schema": "^3.23.1"
},
"engines": {
"node": ">=20"
"node": ">=20.16.0"
}
}
19 changes: 19 additions & 0 deletions packages/class/src/bmi.test.ts
Original file line number Diff line number Diff line change
@@ -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",
);
});
});
});

0 comments on commit af47564

Please sign in to comment.