Knowledge check: Automated testing - Advanced React

Knowledge check: Automated testing - Advanced React

  1. Why is automated testing important? Select all that apply.

    • It reduces human error.

    • It offers a faster feedback cycle, bringing faster validation and helping the development team to detect problems or bugs early.

    • It saves time to development teams.

  2. What are some of the best practices when writing your automated tests? Select all that apply

    • They should resemble the way your software is used.

    • They should be maintainable in the long run.

    • Your tests need to be focused on the implementation details of your components.

  3. Imagine you have a component that renders both an input tag and a label tag with the exact text Comments:. Inside your test, you have the below piece of code:

     const element = screen.getByLabelText(/Comments:/);
    
    • The label element

    • The input element

    • The document object

  4. In a particular test that’s been written for a form component, you encounter the below two lines of code. What kind of data would the handleSubmit variable represent?

     const handleSubmit = jest.fn();
     render(<FeedbackForm onSubmit={handleSubmit} />);
    
    • A copy of the real function that’s used in the parent component that renders the FeedbackForm.

    • A mock function to track how is called by external code and thus explore the arguments passed in.

    • A specific function jest provides to handle form submissions

  5. What are some of the benefits of Continuous Integration (CI)? Select all that apply.

    • Find bugs earlier and fix them faster.

    • Improved developer productivity.

    • Faster manual integrations.

    • Deliver working software more often.