Skip to content

Commit 20a3628

Browse files
committed
Section 33: A Quick Test Harness
1 parent ae79f80 commit 20a3628

3 files changed

Lines changed: 25 additions & 1 deletion

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module.exports = {
2+
forEach(arr, fn) {
3+
for(let element of arr) {
4+
fn(element)
5+
}
6+
}
7+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
const assert = require('assert')
2+
const { forEach } = require('../index');
3+
4+
it('should sum an array', () => {
5+
const numbers = [1, 2, 3]
6+
7+
let total = 0
8+
forEach(numbers, (value) => {
9+
total += value
10+
})
11+
12+
assert.strictEqual(total, 6)
13+
})

33-Building-a-Testing-Framework-From-Scratch/README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,8 @@
2121

2222
## 5. 06 Collecting Test Files
2323

24-
## 6. 07 Running Test Files
24+
## 6. 07 Running Test Files
25+
26+
## 7. 08 A Quick Test Harness
27+
28+
Terminal command: `testme`

0 commit comments

Comments
 (0)