0
0
React Nativemobile~20 mins

Detox for E2E testing in React Native - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Detox Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
ui_behavior
intermediate
2:00remaining
What does this Detox test check?
Given this Detox test code, what UI behavior is being verified?
React Native
describe('Login screen', () => {
  beforeEach(async () => {
    await device.reloadReactNative();
  });

  it('should show error on empty login', async () => {
    await element(by.id('loginButton')).tap();
    await expect(element(by.text('Please enter username'))).toBeVisible();
  });
});
AChecks that app crashes on empty login
BChecks that login button is disabled initially
CChecks that username input accepts text
DChecks that tapping login without username shows an error message
Attempts:
2 left
💡 Hint
Look at what element is tapped and what text is expected to be visible.
lifecycle
intermediate
1:30remaining
What does device.reloadReactNative() do in Detox?
In Detox tests, what is the purpose of calling device.reloadReactNative() before each test?
AIt restarts the React Native app to a fresh state before each test
BIt reloads only the JavaScript bundle without restarting the app
CIt clears the app cache but keeps the current screen
DIt resets the device to factory settings
Attempts:
2 left
💡 Hint
Think about why tests need a clean start.
📝 Syntax
advanced
2:00remaining
Identify the syntax error in this Detox test snippet
What is the syntax error in this Detox test code?
React Native
it('should login successfully', async () => {
  await element(by.id('usernameInput')).typeText('user');
  await element(by.id('passwordInput')).typeText('pass');
  element(by.id('loginButton')).tap()
  await expect(element(by.id('welcomeMessage'))).toBeVisible();
});
AMissing await before element(by.id('loginButton')).tap()
BMissing semicolon after tap() call
CMissing comma between arguments in typeText()
DMissing closing parenthesis in expect()
Attempts:
2 left
💡 Hint
Check async calls and awaits carefully.
🔧 Debug
advanced
2:30remaining
Why does this Detox test fail with timeout?
This Detox test fails with a timeout error on the last expect statement. Why?
React Native
it('shows welcome after login', async () => {
  await element(by.id('usernameInput')).typeText('user');
  await element(by.id('passwordInput')).typeText('pass');
  await element(by.id('loginButton')).tap();
  await expect(element(by.id('welcomeMessage'))).toBeVisible();
});
AThe tap() call is missing await causing race condition
BThe test is missing a waitFor() to wait for welcomeMessage to appear
CThe welcomeMessage element is not visible because login failed silently
DThe usernameInput and passwordInput IDs are incorrect
Attempts:
2 left
💡 Hint
Consider what happens if login does not succeed.
🧠 Conceptual
expert
3:00remaining
Why use Detox for React Native E2E testing instead of Jest alone?
Which reason best explains why Detox is preferred for end-to-end testing in React Native apps over Jest unit tests?
ADetox is faster than Jest for running unit tests
BDetox runs tests on real devices or emulators simulating user interactions, while Jest tests only logic in isolation
CJest cannot run any tests on React Native apps
DDetox automatically fixes UI bugs during tests
Attempts:
2 left
💡 Hint
Think about what E2E testing means compared to unit testing.