Skip to content

Instantly share code, notes, and snippets.

View RichardBray's full-sized avatar
😎
Fix bug , drink milkshake, code feature, repeat.

Richard Oliver Bray RichardBray

😎
Fix bug , drink milkshake, code feature, repeat.
View GitHub Profile
import * as Store from "./AppContext";
// ...
describe('App', () => {
// ...
describe('Question', () => {
// - context spy
const contextValues = { chosenAnswers: [], setChosenAnswers: () => {} };
// ...
describe("App", () => {
const wrapper = mount(<App />);
// ...
test("Contains a Start and a Finish page", () => {
// - when
const startComp = wrapper.find("Start");
// AppContext.js
import { createContext, useContext } from "react";
export const Store = createContext();
export const useAppContext = () => useContext(Store);
// App.jsx
import React, { Fragment } from "react";
// Context
import { Store, useAppContext } from "./AppContext";
// - Data
import data from "./data.json";
export default function App() {
// App.jsx
import React, { Fragment } from "react";
// - Data
import data from "./data.json";
export default function App() {
function renderQuestions() {
return data.results.map((result, index) => (
@RichardBray
RichardBray / test1.jsx
Last active April 3, 2020 15:52
Enzyme test doc 1 test
// App.jsx
import React, { Fragment } from "react";
// - Data
import data from "./data.json";
export default function App() {
function renderQuestions() {
return data.results.map((result, index) => (
// App.test.js
import React from "react";
import Enzyme, { mount } from "enzyme";
import Adapter from "enzyme-adapter-react-16";
import data from "./data.json";
import App from "./App";
Enzyme.configure({ adapter: new Adapter() });
@RichardBray
RichardBray / enzyme_render_diffs.md
Created March 4, 2019 11:41 — forked from fokusferit/enzyme_render_diffs.md
Difference between Shallow, Mount and render of Enzyme

Shallow

Real unit test (isolation, no children render)

Simple shallow

Calls:

  • constructor
  • render
@RichardBray
RichardBray / tsconfig.json
Created January 10, 2018 11:12
Simple ts configuraiton
{
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"jsx": "react",
"module": "commonjs",
"noImplicitAny": true,
"outDir": "./build/",
"preserveConstEnums": true,
"removeComments": true,
"sourceMap": true,
@RichardBray
RichardBray / creat-react-app.md
Last active October 25, 2018 17:23
Your first component from a fresh create react app project