wix / Detox

Gray box end-to-end testing and automation framework for mobile apps
https://wix.github.io/Detox/
MIT License
11.2k stars 1.92k forks source link

Is it possible to call a native method or package function directly without involving the UI? #4619

Open chiragramimi opened 5 days ago

chiragramimi commented 5 days ago

Description

sample code

import { PassioSDK } from '@passiolife/nutritionai-react-native-sdk-v3'
import { device } from 'detox'

describe('Example', () => {
  beforeAll(async () => {
    jest.setTimeout(300000) // Set timeout to 5 minutes for long-running tests
    await device.launchApp({
      permissions: {
        location: 'inuse',
        camera: 'YES',
        notifications: 'YES',
      },
    })
  })

  beforeEach(async () => {
    await device.reloadReactNative()
  })

  it('should tap on button by id and expect some text to be visible', async () => {
    const result = await PassioSDK.searchForFood('apple')
    expect(result).toBe('Hello from Native!') // Check if the returned value is correct
  }, 300000)
})

Your environment

Detox version: 20.27.3 React Native version: 0.74.3 Node version: 20 Device model: IOS 15 Pro OS: Test-runner (select one): jest

noomorph commented 5 days ago

Someone has to implement this one for the new React Native architecture: https://github.com/wix/Detox/pull/4208

Unfortunately, a couple of people tried and did not succeed for various reasons, so it's still in the embarrassing limbo state. 😕