4. What does arrange-act-assert describe?
- Write the assertion first and the code never
- Set up inputs, perform one action, then check the observable result
- Run the test three times to confirm
- Mock every dependency before writing code
जवाब देखें
जवाब: Set up inputs, perform one action, then check the observable result
A consistent shape makes tests easy to read.
पाठ: describe, it and Arrange-Act-Assert
6. A test passes alone but fails when the whole file runs. What is the most likely cause?
- The file has too many describe blocks
- The test name is too long
- toEqual is slower than toBe
- State leaking between tests, such as a shared object or an unrestored mock
जवाब देखें
जवाब: State leaking between tests, such as a shared object or an unrestored mock
Tests must be independent of order.
पाठ: Setup, Teardown and Test Isolation