Comments (7)
@Rishabh-malhotraa we could use Jest to mock services and generate snapshots for each page. Was this what you had in mind?
from caucus.
Well, I haven't really done a lot of testing myself. I need to do some research about this; I was just thinking of a basic unit test to tell if the updates crash the app or not. Do you mind elaborating your approach a bit?
from caucus.
@Rishabh-malhotraa sure!
Using this approach, Jest will render a React component using a lightweight test render and generate an HTML output, this output is referred to as a snapshot. Asynchronous operations like API responses should be mocked to ensure that the tests run quickly and only app functionality is tested, not the APIs the app calls.
Each time a test is run, the component is rendered and compared to the snapshot. If they are not equal, the test fails. At this point you'll need to decide if the changes to the HTML were intended, if they were, you'll need to update the snapshot to the render result of the latest test run.
Pros of snapshot testing:
- Tests can be created quickly
- Unintended changes are quickly revealed
- Component logic can be tested without extracting the code into separate functions
Cons of snapshot testing:
- Repository size will increase significantly (the snapshots must be stored in the repo)
- It can be difficult to track down why the test failed, especially if the tested component has alot of logic
Sorry if I'm not doing a great job explaining this, check the docs for more info
from caucus.
I suggested this because it would (imo) be the fastest way to setup some initial tests that can verify if new changes break the app or have unintended side effects.
Ideally you'd have unit tests as well to test individual classes/methods, I just thought snapshots might be a good starting point. I'm fairly new to client side testing too though - I'm interested to hear what you think 😄
from caucus.
I suggested this because it would (imo) be the fastest way to setup some initial tests that can verify if new changes break the app or have unintended side effects.
Ideally you'd have unit tests as well to test individual classes/methods, I just thought snapshots might be a good starting point. I'm fairly new to client side testing too though - I'm interested to hear what you think smile
Using just snapshot testing is not quite helpful, try to test all API calls, fire events, state of app, existence of children in different renders and other functionality of the app, i will join you to write unit test for all the components in coming days, please spend a little time on React Testing Library, it will help to guide you in a right way.
https://testing-library.com/docs/react-testing-library/intro/
from caucus.
Using just snapshot testing is not quite helpful, try to test all API calls, fire events, state of app, existence of children in different renders and other functionality of the app, i will join you to write unit test for all the components in coming days, please spend a little time on React Testing Library, it will help to guide you in a right way.
https://testing-library.com/docs/react-testing-library/intro/
Sounds good, I'll start playing around with React Testing Library 😄
This will be alot of work! Might I suggest breaking this down into smaller issues so the PRs are easier to review?
from caucus.
That's great, go ahead.
from caucus.
Related Issues (20)
- Fix Users component on the right hand side HOT 4
- Refactor Code for roomID extractions HOT 8
- Keybinds to run Code: shift+Enter HOT 5
- Not supporting async functions in JavaScipt HOT 2
- Language changed by one user in the room isn't reflected to other users. HOT 1
- Improving Contrast on hover HOT 12
- Adding Contributors HOT 1
- Add support for codechef Problem URL HOT 8
- Have a Light mode HOT 3
- Add support for CSES Problem URL HOT 4
- Convert legacy JS files into Typescript files HOT 3
- Bind onEnter event for guest-name text field HOT 3
- Home page is not responsive HOT 6
- Add a tooltip showing key-bind on Run code button HOT 1
- Add pre commit hook with husky HOT 4
- change the codemirror editor to Monaco HOT 1
- Login using providers is not working on local HOT 2
- Local Development Server crashing upon clicking `Run Code` HOT 15
- Problem in y-websocket connection
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from caucus.