in JavaScript by
Q:
JEST Latest TOP 50+ Questions and Answers

1 Answer

0 votes
by

1. Jest works well with other testing libraries like 

Answer: all of the options

2. Jest is used to test _.

Answer:  Java script

3. Jest is a JavaScript unit testing framework.

Answer: True

4. How to install Jest using npm?

Answer: npm install --save-dev jest

5. The below test will pass.

Answer: False

6. You can check strings against regular expressions with ______________ .

Answer: toMatch

7. Jest uses ________ and ________ matchers to test a value is with exact equality

Answer: ToBe , toEqual

8. The number can be compared using

Answer: all of the options

9. To create a mock function, we use jest.fn().

Answer: True

10. ______________ resets all information stored in the mockFn.mock.calls and mockFn.mock.instances arrays.

Answer: mockClear()

11. .mock is a property of mock function, the place where all information about how the function has been called is kept.

Answer: True

12. Jest supports ______________ for Isolating functionality into small, testable units under test.

Answer: Mock fn

13. The Asynchronous code will move on to another task before it finishes.

Answer: True

14. When you execute ______________ Code, it will move on to another task before it finishes.

Answer: asyn

15. Jest will wait until the ______________ callback is called before finishing the test.

Answer: done

16. ______________ is useful when you want to mock functions in certain test cases and restore the original implementation in others.

Answer: mockRestore()

17. ______________ resets all information stored in the mock, including any inital implementation given.

Answer: mockReset()

18. To test a particular function which throws an error when it's called, you can use toThrow.

Answer: True

19. Code coverage tests that how much code is covered under tests

Answer: True

20. ______________ is useful when you want to completely restore a mock back to its initial state.

Answer: mockreset

21. The Synchronous Code will move on to another task before it finishes.

Answer: False

22. What is the command to install Jest and the babel-jest ?

a. $ npm install –dev-save jest babel-jest

b. $ npm install jest --save-dev babel-jest

c. $ npm install --save-dev jest babel-jest

d. $ npm install -save-dev jest babel-jest

Answer:- $ npm install jest --save-dev babel-jest

23. ______________ returns the value only once when mock function is called.

a. mockReturnValue(value)

b. mockReturnOnce(value)

c. mockReturnValueOnce(value)

d. None of the options

Correct answer is:- mockReturnValue(value)

24. How to install Jest using yarn?

Answer: - yarn add --dev jest

25. ______________ is an array that records all the object instances that have been instantiated from the mock function using new.

Answer:- mock.instances

26. Which method is useful to clean up a mock's usage data between two assertions.

Answer:- mockClear()

27. mockRestore() removes the mock and restores the initial implementation

Answer :- True

28. How to install Jest using npm?

a. npm install jest --save-dev

b. npm install --save-dev jest

c. npm add –save-dev jest

d. all the options

Correct answer is: - all the options

Related questions and answers

0 votes
asked Aug 27 in Other by Robin
0 votes
asked Aug 27 in CommVault by Robin
0 votes
asked Aug 17 in SEO by Robin
...