gpt4 book ai didi

ios - 在 Detox 测试不起作用时启用通知

转载 作者:行者123 更新时间:2023-11-29 11:27:39 31 4
gpt4 key购买 nike

我正在尝试使用 device.launchApp({ permissions: { notifications: 'YES' } }) 启用权限,但它似乎没有被调用。

这是我的测试:

describe('Mobile test', () => {
beforeAll(async () => {
await detox.init(config, { launchApp: false });
await device.launchApp({ permissions: { notifications: 'YES' } });
});

describe('Smoke', () => {
it('my test', async () => {
mock.cardData.assignee = mock.signupData.profile.fullName;
await Operator.signup(mock.signupData);
});
});
});

这是使用 verbose loglevel 的测试输出:

detox[8345] INFO:  [DetoxServer.js] server listening on localhost:65156...
detox[8345] DEBUG: [AsyncWebSocket.js/WEBSOCKET_OPEN] opened web socket to: ws://localhost:65156
detox[8345] DEBUG: [DetoxServer.js/LOGIN] role=tester, sessionId=087d9cea-5251-fbda-160a-f89d4927dee3
detox[8345] DEBUG: [DetoxServer.js/LOGIN_SUCCESS] role=tester, sessionId=087d9cea-5251-fbda-160a-f89d4927dee3
detox[8345] DEBUG: [exec.js/EXEC_CMD, #0] /usr/bin/xcrun simctl list -j
detox[8345] DEBUG: [exec.js/EXEC_CMD, #1] applesimutils --list --byType "iPhone X" --byOS "12.2"
detox[8345] DEBUG: [exec.js/EXEC_TRY, #1] Searching for device matching iPhone X...
detox[8345] DEBUG: [exec.js/EXEC_CMD, #2] applesimutils --list --byId "B2E486B7-8CD7-4B94-9969-3C6901591BD8"
detox[8345] DEBUG: [exec.js/EXEC_CMD, #3] /usr/bin/xcrun simctl uninstall B2E486B7-8CD7-4B94-9969-3C6901591BD8 com.amadeu.mobileapp
detox[8345] DEBUG: [exec.js/EXEC_TRY, #3] Uninstalling com.amadeu.mobileapp...
detox[8345] DEBUG: [exec.js/EXEC_SUCCESS, #3] com.amadeu.mobileapp uninstalled
detox[8345] DEBUG: [exec.js/EXEC_CMD, #4] /usr/bin/xcrun simctl install B2E486B7-8CD7-4B94-9969-3C6901591BD8 "/Users/amadeu.filho/Developer/amadeu-mobile/ios/build/Build/Products/Debug-iphonesimulator/amadeumobile.app"
detox[8345] DEBUG: [exec.js/EXEC_TRY, #4] Installing /Users/amadeu.filho/Developer/amadeu-mobile/ios/build/Build/Products/Debug-iphonesimulator/amadeumobile.app...
detox[8345] DEBUG: [exec.js/EXEC_SUCCESS, #4] /Users/amadeu.filho/Developer/amadeu-mobile/ios/build/Build/Products/Debug-iphonesimulator/amadeumobile.app installed
detox[8345] DEBUG: [exec.js/EXEC_CMD, #5] /usr/bin/xcrun simctl terminate B2E486B7-8CD7-4B94-9969-3C6901591BD8 com.amadeu.mobileapp
detox[8345] DEBUG: [exec.js/EXEC_TRY, #5] Terminating com.amadeu.mobileapp...
detox[8345] DEBUG: [exec.js/EXEC_SUCCESS, #5] com.amadeu.mobileapp terminated
detox[8345] DEBUG: [exec.js/EXEC_CMD, #6] SIMCTL_CHILD_DYLD_INSERT_LIBRARIES="/Users/amadeu.filho/Library/Detox/ios/1ea4f89e9092026849f937e47281627c5f5251d6/Detox.framework/Detox" /usr/bin/xcrun simctl launch B2E486B7-8CD7-4B94-9969-3C6901591BD8 com.amadeu.mobileapp --args -detoxServer "ws://localhost:65156" -detoxSessionId "087d9cea-5251-fbda-160a-f89d4927dee3"
detox[8345] DEBUG: [exec.js/EXEC_TRY, #6] Launching com.amadeu.mobileapp...
detox[8345] DEBUG: [exec.js/EXEC_CMD, #7] /usr/bin/xcrun simctl get_app_container B2E486B7-8CD7-4B94-9969-3C6901591BD8 com.amadeu.mobileapp
detox[8345] INFO: [AppleSimUtils.js] com.amadeu.mobileapp launched. To watch simulator logs, run:
/usr/bin/xcrun simctl spawn B2E486B7-8CD7-4B94-9969-3C6901591BD8 log stream --level debug --style compact --predicate 'processImagePath beginsWith "/Users/amadeu.filho/Library/Developer/CoreSimulator/Devices/B2E486B7-8CD7-4B94-9969-3C6901591BD8/data/Containers/Bundle/Application/6F69DC89-7478-4502-8998-8B93E8D061C6/amadeumobile.app"'
detox[8345] DEBUG: [DetoxServer.js/CANNOT_FORWARD] role=testee not connected, cannot fw action (sessionId=087d9cea-5251-fbda-160a-f89d4927dee3)
detox[8345] DEBUG: [DetoxServer.js/LOGIN] role=testee, sessionId=087d9cea-5251-fbda-160a-f89d4927dee3
detox[8345] DEBUG: [DetoxServer.js/LOGIN_SUCCESS] role=testee, sessionId=087d9cea-5251-fbda-160a-f89d4927dee3

我也尝试在应用程序打开时手动调用 applesimutils,但是,我不知道排毒是否使用不同的包来运行测试套件。

➜ applesimutils --byId "B2E486B7-8CD7-4B94-9969-3C6901591BD8" --bundle com.amadeu.mobileapp --setPermissions notifications=YES

我正在使用 iPhone X 模拟器。

      "buildversion" : "16E226",
"availability" : "(available)",
"isAvailable" : true,
"identifier" : "com.apple.CoreSimulator.SimRuntime.iOS-12-2",
"version" : "12.2",
"name" : "iOS 12.2"

最佳答案

看来我们应该在没有启动的情况下初始化排毒,然后使用 device.launchApp({ permissions: { notifications: 'YES' } })

因此,在 init.js 文件中,您可以使用:

const detox = require('detox');
const adapter = require('detox/runners/jest/adapter');
const specReporter = require('detox/runners/jest/specReporter');
const config = require('../package.json').detox;

jest.setTimeout(120000);
jasmine.getEnv().addReporter(adapter);
jasmine.getEnv().addReporter(specReporter);

beforeAll(async () => {
await detox.init(config, { launchApp: false });
await device.launchApp({ permissions: { notifications: 'YES' } });
});

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

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

关于ios - 在 Detox 测试不起作用时启用通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57057132/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com