Skip to content

Instantly share code, notes, and snippets.

View danielnass's full-sized avatar
🚀
Ship it!

Daniel Nass danielnass

🚀
Ship it!
View GitHub Profile
@diegohaz
diegohaz / query.ts
Last active November 30, 2023 21:07
import {
queryByLabelText,
queryByRole,
queryByText,
} from "@testing-library/dom";
import type { ByRoleOptions, Matcher } from "@testing-library/dom";
const roles = [
"alert",
"alertdialog",

Cheat sheet: Arrays

JavaScript Arrays are a very flexible data structure and used as lists, stacks, queues, tuples (e.g. pairs), etc. Some

Using Arrays

Creating Arrays, reading and writing elements:

@KATT
KATT / usage.ts
Last active December 12, 2022 18:25
Test helper utility to expect a function or a promise to throw
// usage examples
// callback
const err1 = await waitError(() => { /* do something that throws */ })
// async callback
const err2 = await waitError(async () => { /* do something async that throws */ })
// expect a promise instance to throw
const err3 = await waitError(promise)
@rishitells
rishitells / Jest_GitLab_CI.md
Last active May 3, 2024 20:18
Setting up Jest tests and coverage in GitLab CI

Configuring Jest Tests in GitLab CI

1. Add GitLab CI configuration file in the root

In the root of your project, add .gitlab-ci.yml with the configuration below.

image: node:latest

stages:
@sindresorhus
sindresorhus / esm-package.md
Last active May 5, 2024 20:24
Pure ESM package

Pure ESM package

The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
<!DOCTYPE html>
<html>
<head>
<title>Caesar Cipher</title>
<style type="text/css">
body {
margin: 0 auto;
max-width: 40em;
width: 88%;
@kuhelbeher
kuhelbeher / readme.md
Last active December 6, 2022 16:20
Eslint airbnb config + prettier for create-react-app project

This is tutorial of onfiguring eslint, prettier for your project

Make your code great again

  1. Eslint

First of all we need to install eslint and configs as dev dependencies. You can use your own config, but I will use config from airbnb:

yarn add -D eslint eslint-config-airbnb eslint-plugin-import eslint-plugin-jsx-a11y eslint-plugin-react
module.exports = {
entry: {
main: path.resolve(__dirname, 'src/index.js'),
ProductList: path.resolve(__dirname, 'src/ProductList/ProductList.js'),
ProductPage: path.resolve(__dirname, 'src/ProductPage/ProductPage.js'),
Icon: path.resolve(__dirname, 'src/Icon/Icon.js'),
},
output: {
path: path.resolve(__dirname, 'dist'),
@Overbryd
Overbryd / 0-README.md
Last active September 11, 2023 19:14
Cloudflare Fragment Caching

Cloudflare fragment rendering/caching

This worker script will evaluate your origin response, and replace html comments marked as fragment:key with a respective prefetch defined in a X-Fragments response header.

Usage

Your origin must include the X-Fragments header, specifying the a comma separated list of prefetch requests to make for that response.

< HTTP/1.1 200 OK