Skip to content

Instantly share code, notes, and snippets.

View rohanBagchi's full-sized avatar

Rohan Bagchi rohanBagchi

View GitHub Profile
@rohanBagchi
rohanBagchi / App.rtl.test.js
Created February 22, 2021 04:18
devto-testing rtl test
import { render, fireEvent, screen } from "@testing-library/react";
import { rest } from "msw";
import { setupServer } from "msw/node";
import App from "./App";
const joke = 'Foo Bar!';
const server = setupServer(
rest.get("https://api.icndb.com/jokes/random", (req, res, ctx) => {
return res(
@rohanBagchi
rohanBagchi / App.enzyme.test.js
Created February 22, 2021 04:16
devto-testing enzyme test
import Enzyme from 'enzyme';
import Adapter from '@wojtekmaj/enzyme-adapter-react-17';
import { shallow } from 'enzyme';
import App from './App';
import axios from 'axios';
Enzyme.configure({ adapter: new Adapter() });
const joke = 'Foo Bar!';
@rohanBagchi
rohanBagchi / App.js
Created February 22, 2021 04:15
devto-testing gist
import "./styles.css";
import { useState } from "react";
import { get } from "axios";
export default function App() {
const [joke, setJoke] = useState(null);
const [error, setError] = useState(null);
const fetchJoke = async () => {
try {
export function CustomPromise(executorFn) {
const PossibleStates = {
PENDING: 'PENDING',
RESOLVED: 'RESOLVED',
REJECTED: 'REJECTED',
};
let currentSuccessResult;
let currentFailureResult;
const listOfSuccessCallbacks = [];
const listOfFailureCallbacks = [];
{
"presets": [
[
"@babel/preset-env",
{
"useBuiltIns": "usage",
"corejs": 2
}
],
"@babel/preset-react"
{
"jest": {
"verbose": true,
"testPathIgnorePatterns": [
"/smoke-tests/"
],
"coverageDirectory": "coverage-client",
"collectCoverageFrom": [
"<rootDir>/src/**/*.js",
"!<rootDir>/webpack/*",
exports.handler = async (event, context) => {
const {
user
} = context.clientContext;
if (user) {
const userID = user.sub;
return {
statusCode: 200,
body: JSON.stringify({
const fetch = require("node-fetch");
exports.handler = async function(event, context) {
const data = JSON.parse(event.body)
const { user } = data
const responseBody = {
user_metadata: {
...user.user_metadata,
}
mutation AddTodo {
insert_todos(objects: {title: "Learning GraphQL", userId: "user-id-1101", complete: false}) {
returning {
complete
date_created
id
title
user {
id
name