Coder Social home page Coder Social logo

QA | Improve tests about curated-tv-and-film HOT 7 CLOSED

lmcjt37 avatar lmcjt37 commented on May 26, 2024
QA | Improve tests

from curated-tv-and-film.

Comments (7)

jnelson180 avatar jnelson180 commented on May 26, 2024 1

I'll make a PR with some Jest tests.

from curated-tv-and-film.

lmcjt37 avatar lmcjt37 commented on May 26, 2024

I have added the basic snapshot tests for the components I have separated out.

Further tests required for methods.

from curated-tv-and-film.

CometS1 avatar CometS1 commented on May 26, 2024

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.

lmcjt37 avatar lmcjt37 commented on May 26, 2024

@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.

CometS1 avatar CometS1 commented on May 26, 2024

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.

lmcjt37 avatar lmcjt37 commented on May 26, 2024

@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.

lmcjt37 avatar lmcjt37 commented on May 26, 2024

Closing as most cases are covered.

from curated-tv-and-film.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.