Jest | Fresco Play
Question 1: The below test will pass.
Answer: False
Question 2: .mock is a property of mock function, the place where all information about how the function has been called is kept.
Answer: True
Question 3: The Asynchronous code will move on to another task before it finishes.
Answer: True
Question 4: Jest will wait until the ______________ callback is called before finishing the test.
Answer: done
Question 5: ______________ resets all information stored in the mock, including any inital implementation given.
Answer: mockReset()
Question 6: To test a particular function which throws an error when it's called, you can use toThrow.
Answer: True
Question 7: Code coverage tests that how much code is covered under tests
Answer: True
Question 8: ______________ is useful when you want to completely restore a mock back to its initial state.
Answer: mockReset()
Question 9: ______________ returns the value only once when mock function is called.
Answer: mockReturnValueOnce(value)
Question 10: How to install Jest using yarn?
Answer: yarn add --dev jest
Question 11: Which method is useful to clean up a mock's usage data between two assertions.
Answer: mockClear()
Question 12: mockRestore() removes the mock and restores the initial implementation
Answer: True
Question 13: Jest is maintained by ______________ .
Answer: Facebook
Question 14: Jest records all calls that have been made during mock function and it is stored in ______________ array.
Answer: mock.calls
Question 15: Jest is used by ______________.
Answer: All of these
Question 16: Snapshot Testing is not supported in Jest.
Answer: False
Question 17: How to run your test in terminal?
Answer: npm test
Question 18: Function's actual implementations can be mocked in test using ____________.
Answer: Both
Question 19: ______________ recursively checks every field of an object or array.
Answer: toEqual
Question 20: The matcher toContain is used _________.
Answer: To check if an array contains a particular item
Question 21: Jest works well with other testing libraries like
Answer: all the options
Question 22: Jest is used to test _.
Answer: Java script
Question 23: Jest is a JavaScript unit testing framework.
Answer: True
Question 24: How to install Jest using npm?
Answer: npm install --save-dev jest
Question 25: You can check strings against regular expressions with ______________ .
Answer: toMatch
Question 26: Jest uses ________ and ________ matchers to test a value is with exact equality
Answer: ToBe , toEqual
Question 27: The number can be compared using
Answer: All the options
Question 28: To create a mock function, we use jest.fn().
Answer: True
Question 29: ______________ resets all information stored in the mockFn.mock.calls and mockFn.mock.instances arrays.
Answer: mockClear()
Question 30: Jest supports ______________ for Isolating functionality into small, testable units under test.
Answer: Mock Functions
Question 31: When you execute ______________ Code, it will move on to another task before it finishes.
Answer: Asynchronous
Question 32: ______________ is useful when you want to mock functions in certain test cases and restore the original implementation in others.
Answer: mockRestore()
Question 33: The Synchronous Code will move on to another task before it finishes.
Answer: False
Question 34: What is the command to install Jest and the babel-jest ?
Answer: $ npm install --save-dev jest babel-jest
Question 35: ______________ is an array that records all the object instances that have been instantiated from the mock function using new.
Answer: mock.instances
Question 36: ______________ matcher matches only undefined.
Answer: toBeUndefined
Question 37: mockRestore() works only when mock was created with ______________.
Answer: jest.spyOn
Question 38: For Code Coverage Support Jest requires some additional setup and libraries .
Answer: False
Question 39: If you expect a promise to be rejected, use the ______________ matcher. If the promise is fulfilled, the test will automatically fail.
Answer: .rejects
Question 40: Snapshot testing is a useful feature if you want to make sure your UI does not change unexpectedly.
Answer: True
Question 41: Predict the output of the test.
Answer: a b a
Post a comment
Get your FREE PDF on "100 Ways to Try ChatGPT Today"
Generating link, please wait for: 60 seconds
Comments
Join the conversation and share your thoughts! Leave the first comment.