Free Jasmine JavaScript MCQ Questions and Answers — Questions and Answers
Question 1: Jasmine was created by
- Pivotal Labs (Correct answer)
- Pivotal Inc
- Pivotal Company
- Pivotal Solutions
Correct answer: Pivotal Labs
Jasmine, a popular behavior-driven development (BDD) testing framework for JavaScript, was originally developed by Pivotal Labs. Pivotal Labs is a software development consultancy known for its agile methodologies and contributions to open-source projects.
Question 2: As a testing framework, Jasmine is
- Propriety
- Open Source (Correct answer)
- Versatile
- Close Source
Correct answer: Open Source
Jasmine is an open-source testing framework. This means its source code is publicly available, allowing developers to freely use, modify, and distribute it. Its open-source nature fosters community contributions and widespread adoption in the JavaScript ecosystem.
Question 3: What had been created before Jasmine was created?
- Screwunit
- Jquery
- JSunit (Correct answer)
- RSpec
Correct answer: JSunit
Before Jasmine's creation, JSUnit was a prominent JavaScript unit testing framework. Jasmine emerged as a more modern, behavior-driven alternative, offering a cleaner syntax and built-in features like test doubles, which were often missing in earlier frameworks like JSUnit.
Question 4: What programming language was used to create Jasmine?
- Python
- Scala
- Java
- JavaScript (Correct answer)
Correct answer: JavaScript
Jasmine is a testing framework specifically designed for JavaScript applications. It is written entirely in JavaScript, allowing it to seamlessly integrate into JavaScript projects for testing both front-end and back-end code.
Question 5: Jasmine could be compared to a
- Cross-platform framework (Correct answer)
- Dual Platform framework
- Single Platform framework
- Al platform framework
Correct answer: Cross-platform framework
Jasmine is considered a cross-platform framework because it can be used to test JavaScript code across various environments. This includes web browsers, Node.js, and even mobile platforms through frameworks like React Native, making it highly versatile for different development needs.
Question 6: Jasmine initially came out in
- 2012
- 2014
- 2010 (Correct answer)
- 2017
Correct answer: 2010
Jasmine was initially released in 2010. Since its debut, it has undergone continuous development and updates, establishing itself as a widely used and respected tool for testing JavaScript applications due to its clear syntax and comprehensive features.
Question 7: The following are all characteristics of Jasmine, except.
- Supports testing front-code
- Make use of spies
- Automation
- Supports asynchronous testing (Correct answer)
Correct answer: Supports asynchronous testing
The question asks to identify which statement is *not* a characteristic of Jasmine. Jasmine is a JavaScript testing framework that explicitly includes built-in support for asynchronous operations, using mechanisms like the `done()` callback and `async/await` syntax. Therefore, 'Supports asynchronous testing' is actually a core characteristic of Jasmine, implying a potential factual error in the question or the designated correct answer.
Question 8: What distinguishes Jasmine from Mocha?
- Readable syntax
- Presence of test doubles in Jasmine (Correct answer)
- Absence of command line utility in Mocha
- Presence of command line utility in Mocha
Correct answer: Presence of test doubles in Jasmine
A key distinction between Jasmine and Mocha is Jasmine's built-in support for test doubles, such as spies, mocks, and stubs, through functions like `spyOn()`. Mocha, while also a popular JavaScript testing framework, typically requires external libraries like Sinon.js to provide similar test double functionality.
Question 9: Jasmine is in favor of the following, although
- Compilation (Correct answer)
- Test-driven development
- Synchronous testing
- Behavioral driven development
Correct answer: Compilation
Jasmine is a runtime testing framework for JavaScript, which is an interpreted language, and therefore does not inherently favor compilation as a core aspect of its testing philosophy. While modern JavaScript development often involves transpilation or bundling, Jasmine itself focuses on testing code in its execution environment rather than requiring a compilation step for the tests themselves.
Question 10: Aside from those listed below, Jasmine is influenced by
- RSpec
- Npm (Correct answer)
- JSpec
- JSSpec
Correct answer: Npm
Jasmine's syntax and philosophy were heavily influenced by other behavior-driven development (BDD) frameworks like RSpec, JSpec, and JSSpec. These frameworks provided the inspiration for Jasmine's readable `describe` and `it` syntax, which emphasizes describing behavior rather than just testing units. Npm, on the other hand, is a package manager and not a direct influence on Jasmine's testing methodology.
Question 11: Which Jasmine function is used to determine the number of times a function has been called?
- `spyOnCount()`
- `toHaveBeenCalled()`
- `toHaveBeenCalledTimes()` (Correct answer)
- `callCount()`
Correct answer: `toHaveBeenCalledTimes()`
The `toHaveBeenCalledTimes()` matcher in Jasmine is specifically used to verify how many times a spy or a mocked function has been invoked during a test. It allows developers to assert that a function was called an exact number of times, which is crucial for testing interaction counts.
Jasmine was created by