Comments (7)
I'll make a PR with some Jest tests.
from curated-tv-and-film.
I have added the basic snapshot tests for the components I have separated out.
Further tests required for methods.
from curated-tv-and-film.
I would like to make some tests for the methods. Do you know how to test to see how the state has changed?
from curated-tv-and-film.
@CometS1 You should be able to do a shallow
render of the component. Then expect
the state to change after a method call, checking this before and after.
eg. You have a state of disabled for <Component/>
it(‘should change state’, () => {
const wrapper = shallow(<Component />);
expect(wrapper.state().disabled).toEqual(true);
wrapper.instance().method(); // I believe this is right - you may need to spy on the method
expect(wrapper.state().disabled).toEqual(false);
});
from curated-tv-and-film.
I was making a test for the showFilters state to see whether the toggle would change its state, and managed to get it working on a previous version, but when I updated to the current version of the repository, it now says that it no longer can read the state. Here is my current code:
`it('testing for changed toggle state', () => {
const wrapper = shallow();
expect(wrapper.state().showFilters).toEqual(false);
wrapper.instance().toggleFilter();
expect(wrapper.state().showFilters).toEqual(true);
}); `
And I get the error "Cannot read property 'showFilters' of null". Do you know if any recent changes would have caused it?
from curated-tv-and-film.
@CometS1 The project has come on quite a bit since Hacktoberfest.
I have broken the project into separate components and changed the testing strategy. These could have both had an impact of how your tests were originally running?
I can always help you work through the code if you commit a PR, I do have a slack workspace too which I can add you too if you want to talk around any other areas of the project.
from curated-tv-and-film.
Closing as most cases are covered.
from curated-tv-and-film.
Related Issues (20)
- Tech | Update packages
- Tests | Fix breaking change HOT 1
- Tech | Update CI branch filter
- UX | Add delete to search HOT 7
- Tech | Switch CI to Github actions HOT 3
- UI | New favicon HOT 8
- Tech | Refactor components HOT 4
- [Tech] Typescript HOT 2
- Tech | Refactor app.js HOT 2
- [Design] Add animation when switching view layout HOT 3
- [Design] Dark mode HOT 3
- Docs | update CI badge
- UI | Only show delete when text in searchbar HOT 5
- Bug | Fix horizontal scroll HOT 2
- [Tech] Context API HOT 5
- [A11y] Accessibility
- [Tech] Improve pipeline
- [Tech] Remove testing from pre-commit
- [Documentation] Update to reflect migration to yarn
- [Tech] Integrate OMDB api
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 curated-tv-and-film.