Skip to content

Instantly share code, notes, and snippets.

View kentcdodds's full-sized avatar
🤓
working hard to make the world better with software

Kent C. Dodds kentcdodds

🤓
working hard to make the world better with software
View GitHub Profile
// please check https://docs.netlify.com/configure-builds/environment-variables/#declare-variables for most up to date info
// this was created before those docs existed
process.env = {
/**
*
* AUTOMATICALLY SET BY NETLIFY. IMMUTABLE!
* docs: https://www.netlify.com/docs/continuous-deployment/#environment-variables
*
*/
@kentcdodds
kentcdodds / 0. README.md
Last active February 15, 2023 14:19
coverage information for https://testingjavascript.com

Code Coverage

Code coverage is accomplished with Jest thanks to babel-plugin-istanbul. It transforms your code to "instrument" it for coverage. When your tests are finished, Jest reads the coverage data to generate the coverage report.

Reviewing code that has been instrumented for coverage can help understanding how coverage works and how to interpret coverage reports.

@sebmarkbage
sebmarkbage / WhyReact.md
Created September 4, 2019 20:33
Why is React doing this?

I heard some points of criticism to how React deals with reactivity and it's focus on "purity". It's interesting because there are really two approaches evolving. There's a mutable + change tracking approach and there's an immutability + referential equality testing approach. It's difficult to mix and match them when you build new features on top. So that's why React has been pushing a bit harder on immutability lately to be able to build on top of it. Both have various tradeoffs but others are doing good research in other areas, so we've decided to focus on this direction and see where it leads us.

I did want to address a few points that I didn't see get enough consideration around the tradeoffs. So here's a small brain dump.

"Compiled output results in smaller apps" - E.g. Svelte apps start smaller but the compiler output is 3-4x larger per component than the equivalent VDOM approach. This is mostly due to the code that is usually shared in the VDOM "VM" needs to be inlined into each component. The tr

@kentcdodds
kentcdodds / index.js
Created September 10, 2019 22:26
NodeJS file runner for Jest (create-node-runner using create-jest-runner). Use this with the runner option in jest config.
const {createJestRunner} = require('create-jest-runner')
module.exports = createJestRunner(require.resolve('./node-runner'))
@kentcdodds
kentcdodds / package.json
Last active March 6, 2024 01:37
Validates that the versions of tools specified in `engines` in the package.json are installed on the machine.
{
"name": "workshop-computer-validator",
"version": "1.0.0",
"description": "I use this to validate people's computers have the proper versions of node and npm installed for a workshop",
"bin": "./validate-system.js",
"dependencies": {
"semver": "7.1.3"
}
}
@kentcdodds
kentcdodds / autofill-feedback-email.js
Last active April 19, 2023 04:59
I use this to automatically fill in email addresses in feedback forms throughout workshop material
#!/usr/bin/env node
const path = require('path')
const inquirer = require('inquirer')
const replace = require('replace-in-file')
const isCI = require('is-ci')
const spawn = require('cross-spawn')
const fileGlob = process.argv[2] || 'src/**/*.*'
const files = path.isAbsolute(fileGlob)
@kentcdodds
kentcdodds / package.json
Last active April 30, 2024 05:39
setup script for my workshops
{
"name": "workshop-setup",
"version": "1.0.0",
"description": "This is the common setup script for most of my workshops",
"bin": "./setup.js"
}
@kentcdodds
kentcdodds / fix-links.js
Last active April 19, 2021 17:05
I use this to automatically fix links in my react workshops
@kentcdodds
kentcdodds / fix-feedback-links.js
Last active December 3, 2020 20:43
I use this to automatically fix links in my react workshops. (This one's only for the testing-react-apps repo because those markdown files aren't rendered in a UI, the normal one is at https://gist.github.com/kentcdodds/436a77ff8977269e5fee39d9d89956de)
@kentcdodds
kentcdodds / add-discord-role.js
Last active August 21, 2021 16:29
An example of how you can add a role to a user with discord.js
const Discord = require('discord.js')
// your bot token
const token = 'NzM4MDk2NjA4NDQwNDgzODcw.XyG8CA.RbwIBFnAbrRDYOlTdLYgG_T4CMk'
const discordUsername = 'example#1234'
const roleToAdd = 'Cool Person'
const guildName = 'Your Guild Name'
function deferred() {
let resolve, reject