Skip to content

Commit 7d408d0

Browse files
committed
Added a post on tcr with typescript
1 parent be50df2 commit 7d408d0

5 files changed

+680
-23
lines changed

_posts/2019-01-11-trying-out-test-commit-or-revert.md

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ tags:
1111

1212
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.
1313

14+
I have [updated this to modern tools here](2025-10-29-trying-out-test-commit-or-revert-modern.md)
15+
1416
**[UPDATED]**
1517

1618
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)
4850
Here are the commands I ran to get started:
4951

5052
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
5957

6058
```json
6159
"scripts": {
@@ -66,10 +64,9 @@ Here are the commands I ran to get started:
6664
```
6765

6866
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`:
7370

7471
```javascript
7572
/* global describe, it */
@@ -82,11 +79,9 @@ Here are the commands I ran to get started:
8279
});
8380
```
8481

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
9085

9186
## Setting up TCR workflow in package.json
9287

_posts/2019-08-24-scraping-functionally---to-save-my-inheritance.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ mkdir abbesaysscraper && cd abbesaysscraper
5959
npm init -y
6060
npx gitignore node
6161
git init .
62-
npm I axios cheerio
63-
npm I -D standard
62+
npm i axios cheerio
63+
npm i -D standard
6464
touch index.js
6565
```
6666

_posts/2021-06-17-introducing-scradd---the-script-adder.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Let’s say that you are writing a tutorial on how to test next apps. You want t
2020
npx create-next-app demo
2121
cd demo
2222
npx scradd . test "mocha . -R dot -w"
23-
npm I -D mocha
23+
npm i -D mocha
2424
```
2525

2626
I don't expect this tool to be widely used and spread but I was pretty fun to write it - the testing was particularly tricky to get working.

_posts/2022-11-17-nextjs---testing-async-react-components.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ But, as I wrote in the beginning, this is nothing that Next package up for us.
165165
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:
166166

167167
```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
169169

170170
npx -y scradd . "test" "jest"
171171
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
295295
Run this:
296296

297297
```bash
298-
npm I -D jest-fetch-mock
298+
npm i -D jest-fetch-mock
299299
```
300300

301301
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`
343343

344344
Other than that - it now works and we can test our `async` server component using a fake `fetch`.
345345

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`).
347347

348348
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.
349349

0 commit comments

Comments
 (0)