This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const findKeysWithNumericValue = (obj, keyPath = "") => { | |
| const keys = Object.keys(obj) | |
| const numericKeys = [] | |
| const preKey = keyPath.length > 0 ? `${keyPath}.` : "" | |
| for (let k of keys) { | |
| const value = obj[k] | |
| if (typeof value === "number") { | |
| numericKeys.push(`${preKey}${k}`) | |
| } else if (typeof value === "object") { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import "@testing-library/jest-dom/extend-expect"; | |
| import { cleanup } from "@testing-library/react"; | |
| import { axe, toHaveNoViolations } from "jest-axe"; | |
| // stop RTL from cleaning up after itself so we can assert on DOM after tests with aXe | |
| process.env.RTL_SKIP_AUTO_CLEANUP = "true"; | |
| // configure aXe | |
| expect.extend(toHaveNoViolations); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from "react"; | |
| import { render as RTLRender } from "@testing-library/react"; | |
| import { NextRouter } from "next/router"; | |
| import { RouterContext } from "next/dist/next-server/lib/router-context"; | |
| interface RenderOptions { | |
| router: Partial<NextRouter>; | |
| } | |
| export const render = (Component: JSX.Element, options?: RenderOptions) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { createTestClient } from "apollo-server-testing"; | |
| import { ApolloServer } from "apollo-server"; | |
| import { | |
| createResolvers, | |
| typeDefs, | |
| createContext, | |
| Context, | |
| CreateContextOptions, | |
| } from "./server"; | |
| import { DocumentNode } from "graphql"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from "react"; | |
| import { ErrorBoundary } from "./error-boundary"; | |
| export const App = () => { | |
| return ( | |
| <React.StrictMode> | |
| <ErrorBoundary report={console.error}> | |
| <h1>Example</h1> | |
| </ErrorBoundary> | |
| </React.StrictMode> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export interface Package { | |
| name: string; | |
| version: string; | |
| description?: string; | |
| keywords?: string[]; | |
| homepage?: string; | |
| bugs?: { | |
| url: string; | |
| email: string; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # remove all node_modules directories | |
| find . -name node_modules | xargs rm -rf | |
| # remove ll coverage directories | |
| find . -name coverage | xargs rm -rf | |
| # you get the gist... heh |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { spawn } from "child_process"; | |
| import terminate from "terminate"; | |
| export interface RunCliCommandOptions { | |
| cwd?: string; | |
| } | |
| export const runCliCommand = ( | |
| command: string, | |
| options: RunCliCommandOptions = { cwd: process.cwd() } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import chalk from "chalk"; | |
| const containsInOrder = (received: string[], expected: string[]) => { | |
| let lastIndex = 0; | |
| const lastOccuranceMap: { [key: string]: number } = {}; | |
| for (let e of expected) { | |
| const index = received.indexOf(e); | |
| // Not present at all |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import fs from "fs"; | |
| import path from "path"; | |
| import { prettyDOM } from "@testing-library/react"; | |
| const writeDomToFile = (filename = "test-dom.html") => { | |
| const dom = prettyDOM(document.body, 9999999, { highlight: false }); | |
| fs.writeFileSync(path.resolve(__dirname, filename), dom); | |
| } |