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: _posts/2019-01-11-trying-out-test-commit-or-revert.md
+12-17Lines changed: 12 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,6 +11,8 @@ tags:
11
11
12
12
I stumbled over a new concept the other day. As it was conceived by Kent Beck, that inspired and thought me a lot in the past, I got interesting.
13
13
14
+
I have [updated this to modern tools here](2025-10-29-trying-out-test-commit-or-revert-modern.md)
15
+
14
16
**[UPDATED]**
15
17
16
18
I read Kent's blog post a bit too fast and missed that this idea was actually proposed by [Oddmund Strømmer](https://twitter.com/jraregris). Very sorry that I missed that in my writeup, Oddmund. Thanks for correcting me, [Raquel](https://rachelcarmena.github.io/2018/11/13/test-driven-programming-workflows.html).
@@ -48,14 +50,10 @@ You can find [my code here](https://github.com/marcusoftnet/fizzbuzz-tcr)
48
50
Here are the commands I ran to get started:
49
51
50
52
1.`mkdir fizzbuzz-tcr && cd fizzbuzz-tcr` to create the directory and jump into it
51
-
52
-
2.`npm init -y` to create an empty `package.json` file
53
-
54
-
3.`npm I -D mocha chai standard` to install the tools I need
55
-
56
-
4.`touch index.js index.test.js` to setup the two files we will work in
57
-
58
-
5. I wrote scripts for test, lint and pretest
53
+
1.`npm init -y` to create an empty `package.json` file
54
+
1.`npm i -D mocha chai standard` to install the tools I need
55
+
1.`touch index.js index.test.js` to setup the two files we will work in
56
+
1. I wrote scripts for test, lint and pretest
59
57
60
58
```json
61
59
"scripts": {
@@ -66,10 +64,9 @@ Here are the commands I ran to get started:
66
64
```
67
65
68
66
1. I'm linting my code with [standard js](https://standardjs.com/)
69
-
2. The testing is done using [mocha](https://mochajs.org/)
70
-
3. And the `pretest` script is automatically running the linting before the tests are executed
71
-
72
-
6. I then wrote the first test to check that my infrastructure worked. In the `index.text.js`:
67
+
1. The testing is done using [mocha](https://mochajs.org/)
68
+
1. And the `pretest` script is automatically running the linting before the tests are executed
69
+
1. I then wrote the first test to check that my infrastructure worked. In the `index.text.js`:
73
70
74
71
```javascript
75
72
/* global describe, it */
@@ -82,11 +79,9 @@ Here are the commands I ran to get started:
82
79
});
83
80
```
84
81
85
-
7. By running `npm t` I linted and ran the first test
86
-
87
-
8. I created a `.gitignore` from the excellent <https://www.gitignore.io/> using `npx gitignore node`
88
-
89
-
9. Finally, I initialized git and made a first commit `git init` initial commit
82
+
1. By running `npm t` I linted and ran the first test
83
+
1. I created a `.gitignore` from the excellent <https://www.gitignore.io/> using `npx gitignore node`
84
+
1. Finally, I initialized git and made a first commit `git init` initial commit
Copy file name to clipboardExpand all lines: _posts/2022-11-17-nextjs---testing-async-react-components.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -165,7 +165,7 @@ But, as I wrote in the beginning, this is nothing that Next package up for us.
165
165
In order make this happen there are a few things we need to install and configure. Run these commands and I'll describe what happened below:
166
166
167
167
```bash
168
-
npm I -D @testing-library/react jest @testing-library/jest-dom ts-node jest-environment-jsdom
168
+
npm i -D @testing-library/react jest @testing-library/jest-dom ts-node jest-environment-jsdom
169
169
170
170
npx -y scradd ."test""jest"
171
171
npx -y scradd ."test:watch""npm t -- --watch"
@@ -295,7 +295,7 @@ We now have two, quite similar, options. We can supply a _real_ fetch for the `j
295
295
Run this:
296
296
297
297
```bash
298
-
npm I -D jest-fetch-mock
298
+
npm i -D jest-fetch-mock
299
299
```
300
300
301
301
That is a tool that makes mocking of `fetch` easy. Update the test to this:
@@ -343,7 +343,7 @@ Ok - lots of code here, but it's mainly just me setting up the fake data `luke`
343
343
344
344
Other than that - it now works and we can test our `async` server component using a fake `fetch`.
345
345
346
-
Oh - you could use a _real_ fetch too, I presume., if you wanted, by supplying your component a real implementation, like [`node-fetch`](https://www.npmjs.com/package/node-fetch) (install with `npm I -D node-fetch`).
346
+
Oh - you could use a _real_ fetch too, I presume., if you wanted, by supplying your component a real implementation, like [`node-fetch`](https://www.npmjs.com/package/node-fetch) (install with `npm i -D node-fetch`).
347
347
348
348
I haven't played around with this, since I'm not a fan of having my unit and integration tests depend on APIs. That's what end-to-end tests are for. But I'm quite sure you could make this work.
0 commit comments