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
{ | |
"$schema": "https://aka.ms/codetour-schema", | |
"title": "Testing scopes using jest", | |
"steps": [ | |
{ | |
"file": "src/components/MaterialStandard/materialStandard.scope.js", | |
"description": "We first build an array of objects, where each object contains information about setting up the test, and an assertion. \n\nAssertions included in this structure are - `inDocument`, `notInDocument`, and `calls` ( that tracks no of calls to an api)\n\nA standard structure for a \"test object\" is as follows:\n```js\n{\nname: \"<denotes name of the test that shows up when we run it>\"\ncomponent:<component under test>\nscope:<scope array takes in all the applicable scopes for testing>\nroute:<which route we should render the component with>\nassertion: <one of three assertions writtern as screen => screen ...>\nmockedRoute: <if we are asserting no of calls made to particular endpoint>\ncalls: <asserting no of calls>\n}\n```", | |
"line": 22, | |
"contents": "import React from 'react'\nimport * as materialS |
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
{{% block normal %}} | |
This is a normal styled text block. | |
{{% /block %}} | |
{{% block info %}} | |
This is an info styled text block. | |
{{% /block %}} | |
{{% block warning %}} | |
This is an warning styled text block. |
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 { | |
Card, | |
Typography, | |
CardHeader, | |
Button, | |
Avatar, | |
} from '@material-ui/core' | |
import { makeStyles } from '@material-ui/core/styles' | |
const useStyles = makeStyles((theme) => ({ |
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
[ | |
{ | |
"userId": 1, | |
"id": 1, | |
"title": "Mocked Todo", | |
"completed": false | |
} | |
] |
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
/// <reference types="Cypress" /> | |
describe('Tests todo list', () => { | |
it('Checks todo render', () => { | |
cy.customRoute( | |
{ | |
method: 'GET', | |
url: 'https://jsonplaceholder.typicode.com/todos', | |
response: 'fixture:todo.json', | |
}, |
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
Cypress.Commands.add('customRoute', (args, alias = 'mock') => { | |
cy.server() | |
if (Cypress.env('mock')) { | |
cy.route(args).as(alias) | |
} | |
}) |
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
/// <reference types="Cypress" /> | |
describe('Tests todo list', () => { | |
it('Checks todo render', () => { | |
cy.visit('/') | |
cy.get('h3') | |
.should('have.length', 200) | |
.first() | |
.should('have.text', 'delectus aut autem') | |
}) |
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, { useState, useEffect } from 'react' | |
import Axios from 'axios' | |
const URL = 'https://jsonplaceholder.typicode.com/todos' | |
const App = () => { | |
const [todos, setTodos] = useState([]) | |
useEffect(() => { | |
fetchTodos() | |
}, []) |
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, { useState, useEffect } from 'react' | |
import socketIOClient from 'socket.io-client' | |
const socket = socketIOClient('http://localhost:3000', { | |
transports: ['websocket'], | |
autoConnect: false, | |
}) | |
const App = () => { | |
const [connectionStatus, setConnectionStatus] = useState(false) |
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 PORT = 3000 | |
const app = require('express')() | |
const server = require('http').createServer(app) | |
const io = require('socket.io')(server, { serveClient: false }) | |
const cors = require('cors') | |
app.use(cors()) |
NewerOlder