You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/docs/cli/4-dev/01-mops-test.md
+45-18Lines changed: 45 additions & 18 deletions
Original file line number
Diff line number
Diff line change
@@ -67,7 +67,27 @@ You can also specify `wasi` mode for a specific test file by adding the line bel
67
67
// @testmode wasi
68
68
```
69
69
70
-
**Replica tests**
70
+
### `--replica`
71
+
72
+
Which replica to use to run actor tests.
73
+
74
+
Default `pocket-ic` if `pocket-ic` is specified in `mops.toml` in `[toolchain]` section, otherwise `dfx`.
75
+
76
+
Possible values:
77
+
-`dfx` - use `dfx` local replica
78
+
-`pocket-ic` - use [PocketIC](https://pypi.org/project/pocket-ic/) light replica via [pic.js](https://www.npmjs.com/package/@hadronous/pic) wrapper
79
+
80
+
:::info
81
+
If you run `mops test --replica pocket-ic` AND `pocket-ic` is not specified in `mops.toml` in `[toolchain]` section, Mops will use pocket-ic replica that comes with dfx (`dfx start --pocketic`).
82
+
:::
83
+
84
+
### `--verbose`
85
+
86
+
Show replica logs
87
+
88
+
89
+
90
+
## Replica tests
71
91
72
92
Replica tests are useful if you need to test actor code which relies on the IC API(cycles, timers, canister upgrades, etc.).
73
93
@@ -82,27 +102,34 @@ actor {
82
102
};
83
103
```
84
104
85
-
See example [here](https://github.com/ZenVoich/mops/blob/main/test/storage-actor.test.mo).
Default `pocket-ic` if `pocket-ic` is specified in `mops.toml` in `[toolchain]` section, otherwise `dfx`.
117
+
public func runTests() : async () {
118
+
await test("test name", func() : async () {
119
+
let res = await myCanister.myFunc();
120
+
assert res == 123;
121
+
});
122
+
};
123
+
};
124
+
```
97
125
98
-
Possible values:
99
-
-`dfx` - use `dfx` local replica
100
-
-`pocket-ic` - use [PocketIC](https://pypi.org/project/pocket-ic/) light replica via [pic.js](https://www.npmjs.com/package/@hadronous/pic) wrapper
126
+
Make sure your actor doesn't have a name `actor {`.
101
127
102
-
:::info
103
-
If you run `mops test --replica pocket-ic` AND `pocket-ic` is not specified in `mops.toml` in `[toolchain]` section, Mops will use pocket-ic replica that comes with dfx (`dfx start --pocketic`).
104
-
:::
128
+
Make sure your actor has `runTests` method.
105
129
106
-
### `--verbose`
130
+
See example [here](https://github.com/ZenVoich/mops/blob/main/test/storage-actor.test.mo).
0 commit comments