Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Assemblyscript Unittest Framework

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

Documentation: https://wasm-ecosystem.github.io/assemblyscript-unittest-framework/

## Architecture

- `assembly/` written in Assemblyscript, provides user-accessible testing APIs such as test, inspect, mock, etc.
Expand Down
1 change: 1 addition & 0 deletions docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export default defineConfig({
link: "/api-documents",
items: [
{ text: "Configuration", link: "/api-documents/configuration" },
{ text: "Options", link: "/api-documents/options" },
{ text: "Matchers", link: "/api-documents/matchers" },
{ text: "Mock Function", link: "/api-documents/mock-function" },
{ text: "Report", link: "/api-documents/coverage-report" },
Expand Down
15 changes: 9 additions & 6 deletions docs/api-documents/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,17 @@ module.exports = {
return {
env: {
logInfo(ptr, len) {
if (runtime.exports) {
let arrbuf = runtime.exports.__getArrayBuffer(ptr);
let str = Buffer.from(arrbuf).toString("utf8");
console.log(str);
}
let buf = runtime.exports!.__getArrayBuffer(ptr);
let str = Buffer.from(buf).toString("utf8");
runtime.framework.log(str); // log to unittest framework
console.log(str); // log to console
},
},
console: {
log(ptr) {
runtime.framework.log(runtime.exports!.__getString(msg));
}
}
builtin: {
getU8FromLinkedMemory(a) {
return 1;
Expand All @@ -44,5 +48,4 @@ module.exports = {
/** optional: test result output format, default "table" */
// mode: ["html", "json", "table"],
};

```
7 changes: 6 additions & 1 deletion docs/api-documents/coverage-report.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## Coverage Report

After testing, you can get a html / json / table format test coverage report include "Statements Coverage", "Branches Coverage", "Functions Coverage", "Lines Coverage"
After testing, you can get a html / json / table format test coverage report include:

- Statements Coverage
- Branches Coverage
- Functions Coverage
- Lines Coverage
76 changes: 76 additions & 0 deletions docs/api-documents/options.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
## Options

### Define Config

```
--config <config file> path of config file (default: "as-test.config.js")
```

### Override Config File

There are command line options which can override the configuration in `as-test.config.js`.

```
--temp <path> test template file folder
--output <path> coverage report output folder
--mode <output mode> test result output format
```

### Warning Behavior

```
--coverageLimit [error warning...] set warn(yellow) and error(red) upper limit in coverage report
```

### Run partial test cases

```
--testcase <testcases...> only run specified test cases
--testNamePattern <test name pattern> run only tests with a name that matches the regex pattern
```

There are several ways to run partial test cases:

#### Partial Test Files

Providing file path to `--testcase`. it can specify a certain group of files for testing.

::: tip
`--testcase` can accept multiple file paths.
:::

::: details

```
- a.test.ts
|- case_1
|- case_2
- b.test.ts
|- case_A
- c.test.ts
|- case_4
```

run `as-test --testcase a.test.ts b.test.ts` will match all tests in `a.test.ts` and `b.test.ts`

:::

#### Partial Tests

Providing regex which can match targeted test name to `--testNamePattern`. it can specify a certain group of tests for testing.

::: details

```
- a.test.ts
|- case_1
|- case_2
- b.test.ts
|- case_A
- c.test.ts
|- case_4
```

run `as-test --testNamePattern "case_\d"` will match `case 1`, `case 2`, `case 4`

:::