DetoxCircus tests are not accepting permissions

Created on 5 Jun 2020  路  2Comments  路  Source: wix/Detox

Description

A clear and concise description of what the bug is.

  • [x] I have tested this issue on the latest Detox release and it still reproduces

Reproduction

Provide the steps necessary to reproduce the issue. If you are seeing a regression, try to provide the last known version where the issue did not reproduce.

  1. Using react native 62.2, tests won't run on my iOS device because the permissions are not automatically accepted, even though I am passing them (see code paste below). Tests them timeout
  2. When I run the same tests using a jasmine config, permissions are accepted and the tests work fine

my init.js for jest circus

const detox = require("detox")
const adapter = require("detox/runners/jest/adapter")
const specReporter = require("detox/runners/jest/specReporter")
const assignReporter = require("detox/runners/jest/assignReporter")

const config = require("./config.json")

// Set the default timeout
jest.setTimeout(60000)

// console.log({dto: detoxCircus.getEnv()})

// eslint-disable-next-line
detoxCircus.getEnv().addEventsListener(adapter)
// eslint-disable-next-line
detoxCircus.getEnv().addEventsListener(specReporter)
// eslint-disable-next-line
detoxCircus.getEnv().addEventsListener(assignReporter)

beforeAll(async () => {
    await detox.init({ config, launchApp: false })
    await device.launchApp({
        launchArgs: { detoxPrintBusyIdleResources: "YES" },
        permissions: {
            notifications: "YES",
            camera: "YES",
            medialibrary: "YES",
            photos: "YES",
            microphone: "YES"
        }
    })
}, 60000)

beforeEach(async () => {
    await adapter.beforeEach()
})

afterAll(async () => {
    await adapter.afterAll()
    await detox.cleanup()
})

my init-jasmine.js

const detox = require("detox")
const adapter = require("detox/runners/jest/adapter")
const specReporter = require("detox/runners/jest/specReporter")
const assignReporter = require("detox/runners/jest/assignReporter")

const config = require("./config-jasmine.json")

// eslint-disable-next-line
jasmine.getEnv().addReporter(adapter)

// This takes care of generating status logs on a per-spec basis. By default, jest only reports at file-level.
// This is strictly optional.
// eslint-disable-next-line
jasmine.getEnv().addReporter(specReporter)

// This will post which device has assigned to run a suite, which can be useful in a multiple-worker tests run.
// This is strictly optional.
// eslint-disable-next-line
jasmine.getEnv().addReporter(assignReporter)

// Set the default timeout
jest.setTimeout(90000)

beforeAll(async () => {
    console.log("DETOX init start")
    await detox.init(config, { launchApp: false })

    console.log("DETOX init end")

    console.log("DETOX launchApp start")

    await device.launchApp({
        newInstance: true,
        launchArgs: { detoxPrintBusyIdleResources: "YES" },
        permissions: {
            notifications: "YES",
            camera: "YES",
            medialibrary: "YES",
            photos: "YES",
            microphone: "YES"
        }
    })
    console.log("DETOX launchApp end")
}, 30000)

beforeEach(async () => {
    try {
        await adapter.beforeEach()
    } catch (err) {
        await detox.cleanup()
        throw err
    }
})

afterAll(async () => {
    await adapter.afterAll()
    await detox.cleanup()
})

Expected behavior

A clear and concise description of what you expected to happen.

Environment (please complete the following information):

  • Detox: 16.7.2
  • React Native: 62.2
  • Node: 12+
  • Device: iphone 11 pro max simulator
  • Xcode: latest
  • iOS: latest
  • macOS: latest

If you are experiencing a timeout in your test

triagbug ios

Most helpful comment

I'm pretty sure your issue is that the config is inside the options object
await detox.init({ config, launchApp: false })
it should be
await detox.init(config, {launchApp: false })

All 2 comments

I'm pretty sure your issue is that the config is inside the options object
await detox.init({ config, launchApp: false })
it should be
await detox.init(config, {launchApp: false })

@misoares thank you!! that fixed this.

Was this page helpful?
0 / 5 - 0 ratings