react-app
Cypress
react-app | Cypress | |
---|---|---|
3 | 174 | |
9 | 46,167 | |
- | 0.4% | |
0.0 | 9.8 | |
over 1 year ago | 4 days ago | |
JavaScript | JavaScript | |
- | MIT License |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
react-app
-
How to Add End-to-End Tests to Your React Project
If you want to see the full version of the tests we’ve written today, go to the GitHub Repository for react-app and select the branch called feature/cypress-tests. If you have questions or comments about this post or want to see us write about something else, drop your idea in our blog post ideas discussion thread.
-
How to Migrate your React Project to TypeScript
This is in our handleChange function that’s attached to our element. When our user types in the
</code>, the event is passed to the <code>handleChange</code> function and becomes the value for our <code>setAffirmation</code> hook. We know that we don’t want the type of our event to be <code>any</code>. This is a journal app and that value is text, or more specifically, a string.</p> <p>We need to let the application know that we don’t want it to accept any other type. We’re going to give our function a type of <code>React.ChangeEventHandler<HTMLTextAreaElement></code> since we have access to <code>React.ChangeEventHandler</code> through <code>@types/react</code>. This is what it will look like if you use inline types:<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight javascript"><code><span class="kd">const</span> <span class="nx">handleChange</span><span class="p">:</span> <span class="nx">React</span><span class="p">.</span><span class="nx">ChangeEventHandler</span><span class="o"><</span><span class="nx">HTMLTextAreaElement</span><span class="o">></span> <span class="o">=</span> <span class="p">(</span><span class="nx">e</span><span class="p">)</span> <span class="o">=></span> <span class="p">{</span> <span class="nx">setAffirmation</span><span class="p">(</span><span class="nx">e</span><span class="p">.</span><span class="nx">target</span><span class="p">.</span><span class="nx">value</span><span class="p">)</span> <span class="p">}</span> </code></pre> <div class="highlight__panel js-actions-panel"> <div class="highlight__panel-action js-fullscreen-code-action"> <svg xmlns="http://www.w3.org/2000/svg" width="20px" height="20px" viewbox="0 0 24 24" class="highlight-action crayons-icon highlight-action--fullscreen-on"><title>Enter fullscreen mode</title> <path d="M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z"></path> </svg> <svg xmlns="http://www.w3.org/2000/svg" width="20px" height="20px" viewbox="0 0 24 24" class="highlight-action crayons-icon highlight-action--fullscreen-off"><title>Exit fullscreen mode</title> <path d="M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z"></path> </svg> </div> </div> </div> <p>The next update we need to make is in our <code>handleSubmit</code> function:<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight javascript"><code> <span class="kd">const</span> <span class="nx">handleSubmit</span> <span class="o">=</span> <span class="p">(</span><span class="nx">e</span><span class="p">)</span> <span class="o">=></span> <span class="p">{</span> <span class="nx">e</span><span class="p">.</span><span class="nx">preventDefault</span><span class="p">()</span> <span class="nx">setFinalAffirmation</span><span class="p">(</span><span class="kc">true</span><span class="p">)</span> <span class="p">}</span> </code></pre> <div class="highlight__panel js-actions-panel"> <div class="highlight__panel-action js-fullscreen-code-action"> <svg xmlns="http://www.w3.org/2000/svg" width="20px" height="20px" viewbox="0 0 24 24" class="highlight-action crayons-icon highlight-action--fullscreen-on"><title>Enter fullscreen mode</title> <path d="M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z"></path> </svg> <svg xmlns="http://www.w3.org/2000/svg" width="20px" height="20px" viewbox="0 0 24 24" class="highlight-action crayons-icon highlight-action--fullscreen-off"><title>Exit fullscreen mode</title> <path d="M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z"></path> </svg> </div> </div> </div> <p>If we hover over the <code>e</code>, we get the same message we did above. You might be tempted to type it in the same way, but let’s think about what’s happening here for a second. We’re submitting a completed form here. If we head over to the <a href="https://react-typescript-cheatsheet.netlify.app/docs/basic/getting-started/forms_and_events/#list-of-event-types">React TypeScript Cheatsheet</a>, we’ll find an event type of <code>FormEvent</code>, which they describe as an “Event that occurs whenever a form or form element gets/loses focus, a form element value is changed or the form is submitted.” That sounds like a good choice.<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight javascript"><code><span class="cm">/* submit is a form event */</span> <span class="kd">const</span> <span class="nx">handleSubmit</span> <span class="o">=</span> <span class="p">(</span><span class="nx">e</span><span class="p">:</span> <span class="nx">React</span><span class="p">.</span><span class="nx">FormEvent</span><span class="o"><</span><span class="nx">HTMLFormElement</span><span class="o">></span><span class="p">)</span> <span class="o">=></span> <span class="p">{</span> <span class="cm">/* prevent page from refreshing */</span> <span class="nx">e</span><span class="p">.</span><span class="nx">preventDefault</span><span class="p">()</span> <span class="nx">setFinalAffirmation</span><span class="p">(</span><span class="kc">true</span><span class="p">)</span> <span class="p">}</span> </code></pre> <div class="highlight__panel js-actions-panel"> <div class="highlight__panel-action js-fullscreen-code-action"> <svg xmlns="http://www.w3.org/2000/svg" width="20px" height="20px" viewbox="0 0 24 24" class="highlight-action crayons-icon highlight-action--fullscreen-on"><title>Enter fullscreen mode</title> <path d="M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z"></path> </svg> <svg xmlns="http://www.w3.org/2000/svg" width="20px" height="20px" viewbox="0 0 24 24" class="highlight-action crayons-icon highlight-action--fullscreen-off"><title>Exit fullscreen mode</title> <path d="M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z"></path> </svg> </div> </div> </div> <p>We add a comment there for clarity that submit is a form event, and then we specify the type as an <code>HTMLFormElement</code>.</p> <p>We’ll move on to the last one in this example.</p> <p>Around line 57, we can see that TypeScript is complaining about <code>socketRef.current</code>. If we hover over it, we get this message:<br> <a href="https://res.cloudinary.com/practicaldev/image/fetch/s--MZeL3Owj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uu1y0hn4dvb0xo76tlim.png" class="article-body-image-wrapper"><img src="https://res.cloudinary.com/practicaldev/image/fetch/s--MZeL3Owj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uu1y0hn4dvb0xo76tlim.png" alt="Type 'WebSocket' is not assignable to type 'null'" loading="lazy" width="880" height="151"></a></p> <p>Because we added the WebSocket types package, <code>@types/websocket</code>, we have access to a WebSocket type. However, we don’t set the type on line 57. The actual problem is with <code>const socketRef = useRef(null)</code>.</p> <p>We need to let TypeScript know that we’re looking at a WebSocket or null: <code>const socketRef = useRef<WebSocket | null>(null)</code>.</p> <p>With that last update, we no longer have TypeScript complaining in this file. That doesn’t mean that there aren’t other updates that we can make. If you hover over other variables or functions, we can see what TypeScript is inferring.</p> <p><a href="https://res.cloudinary.com/practicaldev/image/fetch/s--4MI3Ycnp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ny009v1ukv7hxfz820uo.gif" class="article-body-image-wrapper"><img src="https://res.cloudinary.com/practicaldev/image/fetch/s--4MI3Ycnp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ny009v1ukv7hxfz820uo.gif" alt="gif hovering over code" loading="lazy" width="880" height="357" data-animated="true"></a></p> <p>To complete this migration, we need to update the .js files to .tsx. But the nice thing is that we don’t have to do that all at once. For now, this is where we’ll leave it.</p> <h2> <a name="learn-more-about-typescript" href="#learn-more-about-typescript"> </a> Learn More About TypeScript </h2> <p>There’s a lot to learn about TypeScript. Here are some resources I've found helpful:</p> <ul> <li><a href="https://www.typescriptlang.org/docs/handbook/intro.html">TypeScript Handbook</a></li> <li><a href="https://www.totaltypescript.com/tutorials/beginners-typescript">Totally TypeScript</a></li> <li><a href="https://github.com/typescript-cheatsheets/react#reacttypescript-cheatsheets">React + TypeScript Cheatsheets</a></li> </ul> <p>And check out the Bonus Section of Sandra’s post on how to <a href="https://blog.deepgram.com/build-a-todo-list-with-pinia-and-vue-3/#bonus-section:-add-typescript">Build a To-do List App with Pinia and Vue 3</a>.</p> <p>To access the code for this blog post, select the <code>feature/typescript</code> branch from the <a href="https://github.com/deepgram-devs/react-app">React App GitHub Repository</a>. If you have any thoughts, comments, or questions, please drop a comment in our <a href="https://github.com/orgs/deepgram/discussions/categories/general">General Discussion category</a>, or if you want to say hey, drop your intro in our <a href="https://github.com/orgs/deepgram/discussions/3">intro thread</a>.</p>
-
How to Add Speech Recognition to Your React and Node.js Project
If you want to follow along with this project, you can find the code for the front-end here. To get started quickly, I used Create React App. The file structure for this project will be similar to what you get with Create React App, but you’ll notice that you have a component called Affirmation.js.
Cypress
-
Simulating Internet Outage and Recovery using Cypress
In this blog post, we'll explore a Cypress test that replicates this scenario, utilizing the powerful intercept command to manipulate network requests and responses.
-
Testing Defer Blocks in Angular with Cypress
Recently I came across this issue while triaging some issues at Cypress. (Shout out to MattiaMalandrone for creating an issue with clear instructions for how to reproduce). After quickly replicating the issue I sought after a solution which ultimately inspired me to write this article.
- Cypress changed older versions to block third-party plugins (ignoring lockfiles)
- Cypress can't open Tesla.com website
-
What is Playwright?
While similar to Puppeteer, Cypress, and Selenium, there are some differences. Let’s find out what they are.
- Episode 23/37: ISR in Angular, Cypress & Playwright
-
/Does Cypress Component Testing Work With Libraries
This questions was asked a while ago and pretty much went unanswered: https://github.com/cypress-io/cypress/issues/23677. If it doesn't work with libraries yet I will stop battling with it for now. If it doesn't work, what are you using to test libraries?
- Finally promising Web Testing solution
-
Episode 23/27: NgRx 16.1 & Signal Store, Jest, Cypress, Nx
Cypress Release Notes
- Trouble/Weirdness with accessing aliased values in `this` context
What are some alternatives?
Playwright - Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
Detox - Gray box end-to-end testing and automation framework for mobile apps
jest - Delightful JavaScript Testing.
kafka-test-helper - Utility library that simplify testing of Node.js components that interacts with Kafka broker.
supertest - 🕷 Super-agent driven library for testing node.js HTTP servers using a fluent API. Maintained for @forwardemail, @ladjs, @spamscanner, @breejs, @cabinjs, and @lassjs.
Sentry - Developer-first error tracking and performance monitoring
WebdriverIO - Next-gen browser and mobile automation test framework for Node.js
TestCafe - A Node.js tool to automate end-to-end web testing.
jasmine - Simple JavaScript testing framework for browsers and node.js
pactum - REST API Testing Tool for all levels in a Test Pyramid
Tailwind CSS - A utility-first CSS framework for rapid UI development.
puppeteer - Node.js API for Chrome