Skip to content

Instantly share code, notes, and snippets.

@n8rzz
n8rzz / jest.stores.config.js
Created April 30, 2022 19:58
jest.stores.config.js
const { createJestConfig, jestConfig } = require('./jest.base.config');
const extendedConfig = {
...jestConfig,
rootDir: '../../',
testRegex: '.(store|GlobalStore).test.ts$',
};
module.exports = createJestConfig(extendedConfig);
@n8rzz
n8rzz / jest.ts.config.js
Created April 30, 2022 19:52
jest.ts.config.js
const { createJestConfig, jestConfig } = require('./jest.base.config');
const extendedConfig = {
...jestConfig,
rootDir: '../../',
testRegex: '.test.ts$',
testPathIgnorePatterns: [
...jestConfig.testPathIgnorePatterns,
'^.+\\.(featureFlags|store|stores|services|utils)\\.test.t(s|x)$',
],
@n8rzz
n8rzz / app-index-and-css.tsx
Created January 24, 2022 02:08
app-index-and-css.tsx
/**
* src/App.tsx
*/
import "./styles.css";
import React from "react";
import { Card } from "./Card";
interface IProps {}
export const App: React.FC<IProps> = (props) => {
@n8rzz
n8rzz / card-step-one.test.tsx
Created January 24, 2022 01:28
card-step-one.test.tsx
import React from "react";
import { render } from "@testing-library/react";
import { Card } from "./Card";
describe("Card", () => {
test("does not throw", () => {
const { queryByText } = render(<Card />);
expect(() => queryByText("Card")).not.toThrow();
});
@n8rzz
n8rzz / card-step-one.tsx
Created January 24, 2022 01:26
card-step-one.tsx
import "./styles.css";
import React from "react";
interface IProps {}
export const Card: React.FC<IProps> = (props) => {
return <div className="card">Card</div>;
};
Card.dispalyName = "Card";
@n8rzz
n8rzz / exclusive-if.ts
Created November 18, 2021 20:36
exclusive-if.ts
// bad
function displayName(name) {
if (name) {
return name;
}
return '';
}
// good
@n8rzz
n8rzz / max-final.test.ts
Created October 23, 2021 21:42
max.test.ts - with variables
describe('.max()', () => {
describe('when `valueOne` is equal to `valueTwo`', () => {
test('should return `valueOne`', () => {
const valueOneMock = 1;
const valueTwoMock = 2;
const result = max(valueOneMock, valueTwoMock);
expect(result).toEqual(valueOneMock);
});
});
@n8rzz
n8rzz / max.test.ts
Last active October 23, 2021 21:48
max.test.ts
describe('.max()', () => {
describe('when `valueOne` is equal to `valueTwo`', () => {
test('should return `valueOne`', () => {
const result = max(1, 1);
expect(result).toEqual(1);
});
});
describe('when `valueOne` is less than `valueTwo`', () => {
@n8rzz
n8rzz / find-and-kill-a-process.sh
Created October 23, 2021 16:03
find-and-kill-a-process.sh
lsof -i tcp:PORT_NUMBER # list processes using PORT_NUMBER
kill -9 PID # kill process with pid PID
@n8rzz
n8rzz / ui-experiment-props.tsx
Last active October 30, 2021 23:06
ui-experiment-props.tsx
export enum ExperimentName {
a = 'a',
b = 'b',
}
export type Experiment = {
[key in ExperimentName]: React.ReactNode;
};
interface IProps extends Experiment {