Skip to content

Commit 3675aa6

Browse files
authored
chore: add doc for options (#49)
1 parent 06eae17 commit 3675aa6

File tree

5 files changed

+95
-8
lines changed

5 files changed

+95
-8
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Assemblyscript Unittest Framework
22

3-
<div style="text-align: center;">
3+
<div align="center">
44
<a href="https://deepwiki.com/wasm-ecosystem/assemblyscript-unittest-framework">
55
<img src="https://deepwiki.com/badge.svg" alt="Ask DeepWiki" />
66
</a>
@@ -21,6 +21,8 @@ A comprehensive AssemblyScript testing solution, offering developers a robust su
2121
- Coverage statistics
2222
- Expectations
2323

24+
Documentation: https://wasm-ecosystem.github.io/assemblyscript-unittest-framework/
25+
2426
## Architecture
2527

2628
- `assembly/` written in Assemblyscript, provides user-accessible testing APIs such as test, inspect, mock, etc.

docs/.vitepress/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export default defineConfig({
2121
link: "/api-documents",
2222
items: [
2323
{ text: "Configuration", link: "/api-documents/configuration" },
24+
{ text: "Options", link: "/api-documents/options" },
2425
{ text: "Matchers", link: "/api-documents/matchers" },
2526
{ text: "Mock Function", link: "/api-documents/mock-function" },
2627
{ text: "Report", link: "/api-documents/coverage-report" },

docs/api-documents/configuration.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,17 @@ module.exports = {
2020
return {
2121
env: {
2222
logInfo(ptr, len) {
23-
if (runtime.exports) {
24-
let arrbuf = runtime.exports.__getArrayBuffer(ptr);
25-
let str = Buffer.from(arrbuf).toString("utf8");
26-
console.log(str);
27-
}
23+
let buf = runtime.exports!.__getArrayBuffer(ptr);
24+
let str = Buffer.from(buf).toString("utf8");
25+
runtime.framework.log(str); // log to unittest framework
26+
console.log(str); // log to console
2827
},
2928
},
29+
console: {
30+
log(ptr) {
31+
runtime.framework.log(runtime.exports!.__getString(msg));
32+
}
33+
}
3034
builtin: {
3135
getU8FromLinkedMemory(a) {
3236
return 1;
@@ -44,5 +48,4 @@ module.exports = {
4448
/** optional: test result output format, default "table" */
4549
// mode: ["html", "json", "table"],
4650
};
47-
4851
```

docs/api-documents/coverage-report.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
## Coverage Report
22

3-
After testing, you can get a html / json / table format test coverage report include "Statements Coverage", "Branches Coverage", "Functions Coverage", "Lines Coverage"
3+
After testing, you can get a html / json / table format test coverage report include:
4+
5+
- Statements Coverage
6+
- Branches Coverage
7+
- Functions Coverage
8+
- Lines Coverage

docs/api-documents/options.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
## Options
2+
3+
### Define Config
4+
5+
```
6+
--config <config file> path of config file (default: "as-test.config.js")
7+
```
8+
9+
### Override Config File
10+
11+
There are command line options which can override the configuration in `as-test.config.js`.
12+
13+
```
14+
--temp <path> test template file folder
15+
--output <path> coverage report output folder
16+
--mode <output mode> test result output format
17+
```
18+
19+
### Warning Behavior
20+
21+
```
22+
--coverageLimit [error warning...] set warn(yellow) and error(red) upper limit in coverage report
23+
```
24+
25+
### Run partial test cases
26+
27+
```
28+
--testcase <testcases...> only run specified test cases
29+
--testNamePattern <test name pattern> run only tests with a name that matches the regex pattern
30+
```
31+
32+
There are several ways to run partial test cases:
33+
34+
#### Partial Test Files
35+
36+
Providing file path to `--testcase`. it can specify a certain group of files for testing.
37+
38+
::: tip
39+
`--testcase` can accept multiple file paths.
40+
:::
41+
42+
::: details
43+
44+
```
45+
- a.test.ts
46+
|- case_1
47+
|- case_2
48+
- b.test.ts
49+
|- case_A
50+
- c.test.ts
51+
|- case_4
52+
```
53+
54+
run `as-test --testcase a.test.ts b.test.ts` will match all tests in `a.test.ts` and `b.test.ts`
55+
56+
:::
57+
58+
#### Partial Tests
59+
60+
Providing regex which can match targeted test name to `--testNamePattern`. it can specify a certain group of tests for testing.
61+
62+
::: details
63+
64+
```
65+
- a.test.ts
66+
|- case_1
67+
|- case_2
68+
- b.test.ts
69+
|- case_A
70+
- c.test.ts
71+
|- case_4
72+
```
73+
74+
run `as-test --testNamePattern "case_\d"` will match `case 1`, `case 2`, `case 4`
75+
76+
:::

0 commit comments

Comments
 (0)