Skip to content

Commit cdf9b31

Browse files
authored
Merge pull request #32 from lemontree2000/fix/fixed-unit-test-case
fix: Fix the unit test cases for Chapter 1
2 parents 0656855 + a5b0406 commit cdf9b31

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/1/1.4.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ async function sayHi(name) {
5050
try {
5151
// 调用Promise函数
5252
const text = await helloworld(name);
53-
console.dir(text);
53+
console.log(text);
5454
} catch (error) {
5555
console.log(error);
5656
}
@@ -162,6 +162,7 @@ test("test if works correctly", function (t) {
162162
assert.strictEqual(log.mock.callCount(), 1);
163163
});
164164
```
165+
165166
由于我们在测试代码文件引入了`index.js`中的`sayHi`,因此要在`index.js`文件中给该函数加上`export`
166167

167168
```javascript
@@ -177,6 +178,7 @@ export async function sayHi(name) {
177178
"test": "node --test"
178179
},
179180
```
181+
180182
其中`--test`命令行标志指示Node.js自动寻找以`.test.js`为结尾的文件,并执行其中的测试代码。
181183
执行测试结果如下。
182184

src/1/1.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -734,7 +734,7 @@ async function sayHi(name) {
734734
try {
735735
// 调用Promise函数
736736
const text = await helloworld(name);
737-
console.dir(text);
737+
console.log(text);
738738
} catch (error) {
739739
console.log(error);
740740
}

0 commit comments

Comments
 (0)