Skip to content

Instantly share code, notes, and snippets.

View alexkrolick's full-sized avatar
🏔️
I may be slow to respond.

Alex Krolick alexkrolick

🏔️
I may be slow to respond.
View GitHub Profile
@bvaughn
bvaughn / react-dom-test-selectors.md
Last active January 9, 2023 15:46
Experimental React DOM test selector API

RFC Test Selectors

Owner: Brian Vaughn


As of facebook/react/pull/22760, the experimental Test Selector API is now available in the experimental release channel.

To test the API, first install the experimental release:

@Myndex
Myndex / OrangeYouGladIHaveNoLife.md
Last active June 19, 2024 13:59
Orange You Wondering About Contrast? Part I of three on the APCA and why contrast is important. Especially orange contrast.

Orange You Wondering About Contrast?

What is contrast anyway? In this context, we are talking about the contrast of text on a background, and more directly, how well you can read that text. While this may seem simple in concept, the reality is not only challenging but increasingly important. The internet destroyed the printing industry nearly overnight. Where there were once magaine and newsstands, there are now empty spaces. And reading in general had dropped 40% in the last two decades.

And the internet is hard to read. Too hard, and it shouldn't be. There are some old existing standards on contrast and readability, some dating back to the last century, that are part of the problem. When WCAG 2 was being worked on nearly two decades ago, computers used bulky CRT monitors, and the iPhone was still on the drawing board.

Back then, cell phones were nothing but a phone, websites were only on your desktop/laptop, and those sites invariably used the same core websafe fonts & basic HTML colors. Served over

good doc! some quick answers -

It seems like act() is being recommended for wrapping all state updates in React tests, but is it necessary to use it everywhere if you can use waitForElement to turn the whole test async?

This is a very good question, and something I grappled with earlier. A couple of things that stood out for me -

  • waiting for an element is indeed pretty close to what a user's experience is like; ie - a user 'waits' for the form to show itself, after which they fill it in and click a button, then 'wait' for the success screen etc. Ultimately, act() makes this test stronger - it'll ensure that effects, and queued promises, have been flushed before you interact with the element. wrapping waitForElement with act() (the async version, ie), will make this invisible to the user, but with the guarantee that their UI is 'stable'.

  • I couldn't assume that all tests would use waitForElement. For example, using timers is common for testing transitions and such. In these scenarios too, ac

// UPDATE: don't use this. when it re-partitions the list when time moves forward, it does not correctly keep hashes
// Use a real merkle tree instead: https://gist.github.com/jlongster/f431b6d75ef29c1a2ed000715aef9c8c
import Timestamp from './timestamp';
// This is a compact data structure that keeps track of a list of
// hashes (representing messages) over a range of time in order to
// figure out what has changed between clients, kinda like a Merkle
// tree. It creates "buckets" that represent different time ranges,
// and divides time into smaller buckets the more recent they are. The

A Redux Story

Developer: "Doo Doo Doo... Working on the new Redux rewrite. Gotta write some fetch actions..."

FETCH_USERS -> function fetchUsersAction() {...}
FETCH_PAGES -> function fetchPagesAction() {...}
FETCH_FRIENDS -> function fetchFriendsAction() {...}
FETCH_GROUPS -> function fetchGroupsAction() {...}
FETCH_EVENTS -> function fetchEventsAction() {...}
@HenrikJoreteg
HenrikJoreteg / extra-args-bundle.js
Created July 23, 2018 03:55
Light graphQL / redux-bundler example
import gqlFetch from '../helpers/gql-fetch'
import config from '../config'
export default {
name: 'extraArgs',
getExtraArgs: store => {
return {
gqlFetch: gqlFetch({
apiUrl: config.apiUrl,
getToken: () => store.selectAuthToken(),
@swalkinshaw
swalkinshaw / tutorial.md
Last active November 13, 2023 08:40
Designing a GraphQL API
@developit
developit / *state-machine-component.md
Last active February 6, 2021 00:44
265b lib for building pure functional state machine components. https://github.com/developit/state-machine-component

state-machine-component

A tiny (265 byte) utility to create state machine components using two pure functions.

🔥 JSFiddle Demo

Usage

The API is a single function that accepts 2 pure functions as arguments:

@alexkrolick
alexkrolick / .gitconfig
Last active July 7, 2018 22:36
Git aliases and tool config
[diff]
tool = vscode
indentHeuristic = true
algorithm = histogram
[difftool]
prompt = false
[difftool "vscode"]
cmd = code --wait --diff $LOCAL $REMOTE
[merge]
keepBackup = false
@alexkrolick
alexkrolick / .zshrc
Last active March 8, 2023 19:26
.zshrc
# Installation
#
# MacOS
#
# mkdir ~/.zsh
# brew install zsh-syntax-highlighting zsh-completions
# touch ~/.zshrc
# touch ~/.profile
#
# Paste this file into `~/.zshrc`