XJavascript.com
Toggle Menu
Home
Online Javascript Compiler
Tutorials
JavaScript Tutorials
TypeScript Tutorials
Blog
All Posts
Testing in JavaScript
Quiz yourself on Jest,Mocha,and other JavaScript testing frameworks.
1. Which company developed the Jest testing framework?
Google
Facebook
Microsoft
Netflix
2. Which of the following are JavaScript testing frameworks? (Select all that apply)
Jest
Mocha
React
Cypress
Express
3. Unit tests focus on testing individual functions or components in isolation.
True
False
4. What does TDD stand for? (full phrase)
5. What is the primary purpose of a mock function in JavaScript testing?
To style UI components
To replace external dependencies
To bundle JavaScript files
To minify test code
6. Which Jest method runs a function before each individual test in a suite?
beforeAll
beforeEach
afterEach
afterAll
7. Which of the following are types of test doubles? (Select all that apply)
Mock
Stub
Spy
Hook
Assertion
8. Cypress is primarily used for writing unit tests.
True
False
9. Name a popular assertion library commonly used with Mocha for testing.
10. In Jest, which assertion checks if a value is truthy?
expect(value).toBeTruthy()
expect(value).isTrue()
expect(value).truthy()
expect(value).assertTrue()
11. How can you handle asynchronous code in Jest tests? (Select all that apply)
Using the done callback
Returning a Promise
Using async/await
Wrapping in setTimeout
Using eval()
12. Integration tests verify interactions between multiple components or modules.
True
False
13. What does E2E stand for in the context of testing? (full phrase)
14. Which testing framework is commonly used with React Testing Library for component testing?
Mocha
Jest
Cypress
Playwright
15. Which tools are used for end-to-end (E2E) testing in JavaScript? (Select all that apply)
Cypress
Playwright
Jest
Puppeteer
Mocha
16. A stub function is used to return predefined values to control test behavior.
True
False
17. What term describes a test that checks if a function throws an expected error?
18. In Jest and Mocha, what does an 'it' block represent?
A test suite
A single test case
A setup function
A teardown function
19. Which layers are part of the testing pyramid? (Select all that apply)
Unit tests
Integration tests
End-to-end tests
Performance tests
Load tests
20. Jest requires an external assertion library to write test assertions.
True
False
Reset
Answered 0 of 0 — 0 correct