Skip to content

Instantly share code, notes, and snippets.

View joernb's full-sized avatar

Joern Buchwald joernb

View GitHub Profile
@joernb
joernb / gist:a9e9e0dfd0dd9aaf76865b8c3fab3e52
Created May 17, 2019 13:48
Mock useState for async act
jest.mock('react', () => {
const react = jest.requireActual('react');
const reactTestingLibrary = jest.requireActual('react-testing-library');
return {
...react,
useState: initial => {
const [state, setState] = react.useState(initial);
return [
state,
@joernb
joernb / package.json
Created February 3, 2022 20:51
Run npm script with .env vars
{
"scripts": {
"env": "NODE_OPTIONS='-r dotenv/config' npm run", // runs a given npm script with .env environment variables
"foo": "curl --user $USER:$PASSWORD $ENDPOINT" // sample script, run this with: npm run env foo
}
}