File tree 2 files changed +4
-2
lines changed
2 files changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -50,7 +50,7 @@ async function sayHi(name) {
50
50
try {
51
51
// 调用Promise函数
52
52
const text = await helloworld (name);
53
- console .dir (text);
53
+ console .log (text);
54
54
} catch (error) {
55
55
console .log (error);
56
56
}
@@ -162,6 +162,7 @@ test("test if works correctly", function (t) {
162
162
assert .strictEqual (log .mock .callCount (), 1 );
163
163
});
164
164
```
165
+
165
166
由于我们在测试代码文件引入了` index.js ` 中的` sayHi ` ,因此要在` index.js ` 文件中给该函数加上` export `
166
167
167
168
``` javascript
@@ -177,6 +178,7 @@ export async function sayHi(name) {
177
178
"test" : " node --test"
178
179
},
179
180
```
181
+
180
182
其中` --test ` 命令行标志指示Node.js自动寻找以` .test.js ` 为结尾的文件,并执行其中的测试代码。
181
183
执行测试结果如下。
182
184
Original file line number Diff line number Diff line change @@ -734,7 +734,7 @@ async function sayHi(name) {
734
734
try {
735
735
// 调用Promise函数
736
736
const text = await helloworld(name);
737
- console.dir (text);
737
+ console.log (text);
738
738
} catch (error) {
739
739
console.log(error);
740
740
}
You can’t perform that action at this time.
0 commit comments