Jasmine is an open-source testing framework for JavaScript. It aims to run on any JavaScript-enabled platform, to not intrude on the application nor the IDE, and to have easy-to-read syntax. It is heavily influenced by other unit testing frameworks, such as ScrewUnit, JSSpec, JSpec, and RSpec. Wikipedia
Jasmine.js MCQs: This section contains multiple-choice questions and answers on the various topics of Jasmine.js. Practice these MCQs to test and enhance your skills on Jasmine.js.
List of Jasmine.js MCQs
1. What is Jasmine.js?
- JavaScript testing framework
- JavaScript mobile development framework
- JavaScript web development framework
Answer: A) JavaScript testing framework
Explanation:
Jasmine.js is a JavaScript testing framework.
2. Is Jasmine.js open-source?
- Yes
- No
Answer: A) Yes
Explanation:
Yes, Jasmine.js is an open-source framework.
3. Does Jasmine.js requires DOM?
- Yes
- No
Answer: B) No
Explanation:
Jasmine.js does not require any DOM.
4. Which architecture does Jasmine.js follows?
- MVM
- BDD
- MVVM
- MVP
Answer: B) BDD
Explanation:
Behaviour-driven development architecture does Jasmine.js follows.
5. A ____ is a set of related type test cases developed for a given file or function.
- Groups
- Cluster
- Suite
- Collection
Answer: C) Suite
Explanation:
A suite is a set of related type test cases developed for a given file or function.
6. Which of the following method is used to define suites?
- Define
- Suits
- Test
- Describe
Answer: D) Describe
Explanation:
Describe method is used to define suites.
7. How many arguments does Describe function take?
- 2
- 3
- 4
- 5
Answer: A) 2
Explanation:
Describe function takes two arguments: a text that describes the collection of tests, and a function that includes the tests.
8. The ____ block is a single test defined with its method.
- Nested Suites block
- Describe Block
- IT block
- Expect block
Answer: C) IT block
Explanation:
The “it” block is a single test defined by its method.
9. ____ is also known as a matcher.
- Nested Suites block
- Describe Block
- IT block
- Expect block
Answer: D) Expect block
Explanation:
Expect block is also known as a matcher.
10. Mainly how many types of matchers does Jasmine provides?
- 5
- 4
- 3
- 2
Answer: D) 2
Explanation:
2 types of matchers Jasmine provides: Inbuilt and user-defined.
11. Which of the following is an inbuilt matcher?
- toBe
- toEqual
- toBeNull
- All of the above
Answer: D) All of the above
Explanation:
Following are the inbuilt matchers:
- toBe
- toEqual
- toBeNull
12. User-defined matcher needs to be defined ____.
- Implicitly
- Explicitly
- Both
Answer: B) Explicitly
Explanation:
Custom matcher needs to be defined explicitly().
13. Which of the following inbuilt matcher just compares if the outcome of the operation sent as an argument to this method matches or not?
- Equal ()
- toMatch ()
- toEqual ()
Answer: C) toEqual ()
Explanation:
toEqual () just compares if the outcome of the operation sent as an argument to this method matches or not.
14. Which of the following inbuilt matcher is used to determine whether a value does not match the output of any function?
- NotEqual ()
- nottoMatch ()
- toEqual ()
- Not.toEqual()
Answer: D) Not.toEqual()
Explanation:
Not.toEqual () is used to determine whether a value does not match the output of any function.
15. In Jasmine, which of the following Boolean matcher is used to determine if the result is true or false?
- toBeTruthy()
- toTruthy():
- CheckTruthy():
Answer: A) toBeTruthy()
Explanation:
toBeTruthy() Boolean matcher is used to determine if the result is true or false.
16. Among toBe () and toEqual () which of the following compares objects recursively and checks property equality, and it is type sensitive.
- toBe ()
- toEqual ()
Answer: B) toEqual ()
Explanation:
toEqual () compares objects recursively and checks property equality, and it is type sensitive.
17. ____ matchers allow us to determine whether an element belongs to the same array or another sequential object.
- Tocheck ()
- toMatch()
- toContain()
Answer: C) toContain()
Explanation:
toContain() matchers allow us to determine whether an element belongs to the same array or another sequential object.
18. Suppose you want to Check to see whether any variables in the code are predefined, then which of the following matcher you will use?
- TobePredefined ()
- toBeDefined
- ToPredefined()
Answer: B) toBeDefined
Explanation:
toBeDefined () Check to see whether any variables in the code are predefined.
19. ____ matcher helps to check null values?
- ToNull()
- Null()
- toBeNull()
Answer: C) toBeNull()
Explanation:
toBeNull () matcher helps to check null values.
20. When we are unsure about the output, we employ the special matcher named as ____.
- Any
- All
- Some
- None
Answer: A) Any
Explanation:
When we are unsure about the output, we employ the special matcher any.
21. How many Spying technologies are available in Jasmine?
- 5
- 4
- 3
- 2
Answer: D) 2
Explanation:
There are two types of spying technology available in Jasmine: SpyOn() and CreateSpy().
22. ____ is a feature integrated into the Jasmine framework that allows you to spy on a specific section of code.
- SpyOn()
- Spy ()
- CreateSpy ()
Answer: A) SpyOn()
Explanation:
SpyOn() is a feature integrated into the Jasmine framework that allows you to spy on a specific section of code.
23. Which of the following command manages the Jasmine Clock, which may be used to regulate the flow of time in your tests?
- Clock ()
- toBeClock ()
- Jasmine.Clock()
Answer: C) Jasmine.Clock()
Explanation:
Jasmine.Clock () command manages the Jasmine Clock, which may be used to regulate the flow of time in your tests.
24. ____ check to see whether any variables were previously undefined.
- toBeNotDefined ()
- toUndefined()
- toBeUndefined ()
Answer: C) toBeUndefined ()
Explanation:
toBeUndefined () check to see whether any variables were previously undefined.
25. When jasmine.js was released?
- 2001
- 2019
- 2010
- 2000
Answer: C) 2010
Explanation:
In 2010 jasmine.js was released.
26. It() is global function or a Local function?
- Global
- Local
Answer: A) Global
Explanation:
it() function is a global function.
27. Which of the following companies uses Jasmine?
- Accenture.
- Walmart.
- E-Commerce.
- GitLab.
- All of the above
Answer: E) All of the above
Explanation:
Following companies use Jasmine:
- Accenture.
- Walmart.
- E-Commerce.
- GitLab.
28. Is toBeTruthy () and toBeFalsy the same?
- Yes
- No
Answer: B) No
Explanation:
toBeFalsy matches the output to be false whereas toBeTruthy matches the output to be true.
29. After each test specification has been executed, ____ method is invoked
- Each ()
- AfterEach ()
- EachAfter()
Answer: B) AfterEach ()
Explanation:
After each test specification has been executed, afterEach() method is invoked.
30. Which of the following are the alternative to Jasmine.js?
- Mocha
- Jest
- Tape
- All of the above
Answer: D) All of the above
Explanation:
Following are the alternatives of Jasmine.js:
- Mocha
- Jest
- Tape