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 COMMAND_DELAY = 50; | |
const COMMAND_LIST =['get', 'visit', 'click', 'trigger', 'type', 'clear', 'reload', 'contains'] | |
for (const command of COMMAND_LIST) { | |
Cypress.Commands.overwrite(command, (originalFn, ...args) => { | |
setTimeout(() => { | |
return originalFn(...args) | |
}, COMMAND_DELAY); | |
}); | |
} |
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
//App.js | |
import React, { useState } from 'react' | |
const App = () => { | |
const [message, setMessage] = useState('websocket is closed') | |
return ( | |
<div className="App"> | |
<p id="websocket">{message}</p> | |
<WebsocketHandler setMessage={setMessage} /> | |
</div> | |
) |
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" /> | |
const manualWebSocket = require('manual-web-socket') // import the package | |
describe('Tests websocket', () => { | |
it('Successfully processes websocket message from server', () => { | |
cy.visit('/') | |
.get('[id=websocket]') | |
.should('have.text', 'websocket is closed') | |
cy.visit('/', { | |
onBeforeLoad(win) { | |
var script = win.document.createElement('script') |
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 fillInStripeForm = () => { | |
const input = [ | |
['cardnumber', '4242424242424242'], | |
['exp-date', '1220'], | |
['cvc', '123'], | |
] | |
cy.wait(1000) | |
cy.get('.__PrivateStripeElement > iframe').each(($element, index, list) => { | |
cy.get($element).then(($iframe) => { | |
const body = $iframe.contents().find('body') |
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
PORT=3000 |
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
require('dotenv').config() | |
const express = require('express') | |
const logger = require('morgan') | |
const app = express() | |
const PORT = process.env.PORT | |
app.use(logger('dev')) | |
app.use(express.json()) //http://expressjs.com/en/api.html#express.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
require('dotenv').config() | |
const express = require('express') | |
const app = express() | |
const PORT = process.env.PORT | |
app.listen(PORT, () => { | |
console.info(`App listening on port ${PORT}`) | |
}) |
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
// /routes/posts.js | |
const express = require('express') | |
const router = express.Router() | |
router.get('/', (req, res, next) => { | |
res.send('You have hit GET /posts endpoint') | |
}) | |
module.exports = router |
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
require('dotenv').config() | |
const express = require('express') | |
const logger = require('morgan') | |
const app = express() | |
const PORT = process.env.PORT | |
app.use(logger('dev')) |
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
//.mocharc.json | |
{ | |
"diff": true, | |
"recursive": true, | |
"extension": ["js"], | |
"package": "./package.json", | |
"slow": 75, | |
"timeout": 7000, | |
"color": true, | |
"exit": true |