Skip to content

Instantly share code, notes, and snippets.

View natterstefan's full-sized avatar
🟨
getting things done 💪🏻

Stefan Natter natterstefan

🟨
getting things done 💪🏻
View GitHub Profile
@natterstefan
natterstefan / README.md
Created February 18, 2020 14:47
Jest | Mock useState

Jest - mock useState

When using import React, { useState } from 'react' in your components, this is how you can mock useState with jest.

@natterstefan
natterstefan / password_autofill_expo_how_to.md
Created March 18, 2020 20:10 — forked from amcvitty/password_autofill_expo_how_to.md
Configure Password Autofill on a React Native Expo app

Password Autofill on a React Native Expo app

Developing an app to accompany our website, worried that we would lose people in the transition if they couldn't remember their password, we were looking to make our app do Password AutoFill, a feature in iOS.

A talk from WWDC introducing the feature: https://developer.apple.com/videos/play/wwdc2017/206/

It works well, but there were a few bumps in the road making it work for React Native on Expo, so here are some notes to help out.

Apple's docs are here: https://developer.apple.com/documentation/security/password_autofill and they say something like this:

@natterstefan
natterstefan / README.md
Last active January 6, 2025 09:42
EditorJS | Inline-Tool-Link (Custom)

Editor.js - Custom Inline Tool "Link"

This is our custom implementation of the Inline Tool "Link" with a target and title attribute.

alt

--> used and tested with @editorjs/editorjs@2.17.0

Related Issues

@natterstefan
natterstefan / README.md
Last active September 3, 2024 14:33
VSCode | Debug tests in Create-React-App (all or single file)

VSCode | Debug tests in Create-React-App (all or single file)

Add launch.json into the .vscode folder.

image

Now, enter the Debug view. Either add debugger into one of the tests or add breakpoints, before you execute one of the scripts.

image

@natterstefan
natterstefan / README.md
Last active August 22, 2024 08:37
Jest | Mock jsdom errors
@natterstefan
natterstefan / README.md
Last active July 9, 2024 20:26
NODE | macOS fix node-gyp

Research | macOS fix node-gyp

visitors

Node

Update asdf

asdf plugin-update --all
@natterstefan
natterstefan / HTMLToReact.tsx
Last active April 8, 2024 13:54
html-react-parser | TypeScript solution
/**
* Works in Next.js 10.x
*/
import React from 'react'
import parse, {
domToReact,
attributesToProps,
Element,
HTMLReactParserOptions,
} from 'html-react-parser'
@natterstefan
natterstefan / README.md
Last active February 23, 2024 19:40
JEST | Debug with Google Chrome and/or VS Code

How to debug Jest tests with Chrome

Taken from Jest's troubleshooting page:

  • Place a debugger; statement in any of your tests, and then, in your project's directory
  • yarn test-debug
  • open Chrome and go to chrome://inspect
  • click on "Open Dedicated DevTools for Node"
  • click on the address displayed in the terminal (usually something like
@natterstefan
natterstefan / moveMouse.js
Created April 27, 2023 19:40
JS Utils | Move Mouse Randomly Forever
// function to generate a random number within a range
function getRandomNumber(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
// function to generate a random mouse coordinate within the viewport
function getRandomCoordinate() {
const x = getRandomNumber(0, window.innerWidth);
const y = getRandomNumber(0, window.innerHeight);
return { x, y };
@natterstefan
natterstefan / README.md
Created January 18, 2023 10:08
Next.js | Catchall including index

Next.js | Catch-All route including index