Node.js and Testing cross interview #6
Node.js Basics:
- What is Node.js, and how does it differ from regular JavaScript?
- What is the purpose of the
package.json file, and how does it differ from package-lock.json?
- What is the difference between
devDependencies and dependencies in NPM?
- How do CommonJS (
require) and ES Modules (import) differ in Node.js?
- What is the
fs module, and how do you perform asynchronous file operations with it?
- Briefly explain what streams are in Node.js and describe their types.
- What is the difference between
path.join and path.resolve, and when would you use each?
- How do environment variables work in Node.js, and how are they used in applications?
- How does Node.js handle errors, and what are common patterns for error handling?
- What is the global object in Node.js, and how does it differ from the browser’s global object?
Testing:
- What is the purpose of unit testing?
- What is integration testing, and what are its main goals?
- How does unit testing differ from integration testing?
- What is end-to-end (E2E) testing, and when should it be used?
- How does E2E testing differ from integration testing?
- What is the testing pyramid, and why is it a useful concept in software testing?
- Explain the principles of the FIRST (Fast, Independent, Repeatable, Self-validating, Timely) acronym in testing.
- What is test-driven development (TDD), and how does it improve software quality?
- What is code coverage, and what are its limitations despite having a high percentage?
- Explain the Arrange-Act-Assert (AAA) pattern and its importance in writing unit tests.
- How does Jest facilitate testing in JavaScript? Provide an example of a simple test.
- What are snapshot tests in Jest, and when should you use them?
- What is mocking, and how does it help isolate dependencies in tests?
- What are stubs in the context of testing, and how do they differ from mocks?
- What are spies in the context of testing, and what is their purpose?
- What is the difference between mocks, stubs, and spies in the context of testing?
- What are flaky tests?
- What are some best practices for organizing test files and test suites?
- How can you use environment variables to configure test environments in Node.js?
- What are best practices for managing environment variables in Node.js testing environments?