wix-incubator / DetoxRecorder

Detox Recorder is a utility for recordings steps for a Detox test as you use your app in Simulator. After recording the test, add expectations that check if interface elements are in the expected state.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Detox Recorder can't read configuration from detox.config.js

Mikuu opened this issue · comments

commented

Describe the Bug
DetoxRecorder only search package.json for configuration

To Reproduce
When the detox configuration is not in package.json but in detox.config.js, the detox recorder command can't find the configuration and return failure.

Expected Behavior
Detox Recorder can read configuration from different configuration files as described here

Actual Behavior

detox recorder --configuration "ios" --outputTestFile "./e2e/RecordedTest.js" --testName "DetoxRecordedTest" --record
Unable to find “detox” object in package.json. See “detox recorder --help” for usage.

Hmm, will take a look, thanks. Recorder is supposed to be familiar with all the config files Detox can work with.

https://github.com/wix/DetoxRecorder/blob/b219928ebc3532ae3be8650c0a27c5ff2c8b317d/DetoxRecorder/DetoxRecorderCLI/main.swift#L134

Could you please run the following command in a separate Terminal and paste the output?

log stream --level debug --style compact --predicate "subsystem=='DetoxRecorder'"

Thanks

Ping

Thanks

commented

hi,

below are the output:

log stream --level debug --style compact --predicate "subsystem=='DetoxRecorder'"
Filtering the log data using "subsystem == "DetoxRecorder""
Timestamp               Ty Process[PID:TID]
2021-01-26 14:23:49.401 I  DetoxRecorderCLI[66458:821b34] [DetoxRecorder:CLI] Parsing arguments
2021-01-26 14:23:49.402 I  DetoxRecorderCLI[66458:821b34] [DetoxRecorder:CLI] Attempting to discover Detox config file

What folder are you running the detox recorder command?

commented

the project root folder, where there are package.json and detox.config.js

I'm having the same issue 'Unable to find “detox” object in package.json. See “detox recorder --help” for usage.'.
In my situation, the configuration is in .detoxrc.js
With copying the device configuration to package.json I managed to make it work for now. But I do prefer not to have this configuration in package.json as we have a lot of devices, so it is nicer to generate the configurations from several arrays

I will take a look now. Apologies for the delay.

Can you please post your config file? If it's not a valid JSON file, Detox Recorder cannot read it.

I stripped it down to this snippet and even with that is does not work:

const configurations = {
    "ios.sim.debug": {
        "binaryPath": "ios/build/Build/Products/Debug-iphonesimulator/tmobileBenReactNative Test.app",
        "build": "xcodebuild -workspace ios/tmobileBenReactnative.xcworkspace -scheme \"tmobileBenReactnative Test\" -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build",
        "type": "ios.simulator",
        "device": {
            "type": "iPhone 11 Pro"
        }
    },
};

const exportConfigs = {
    configurations: {
        ...configurations,
    }
}

module.exports = exportConfigs;

with this same configuration I am able to run the normal tests

stripping out all the javascript and replacing it by the resulting json did make the recorder able to run it. So does the .js files get executed before they are checked?

That is not a valid json file.

Your config file needs to pass this:
http://json.parser.online.fr/

Detox Recorder is not a JS environment. It reads the configuration file as a JSON file, and if unable to parse it, it stops. I will improve the error to explain why it fails.

normal detox does allow the config file to be javascript, so why is there this difference?

Because Detox runs in Node, while Detox Recorder is a native macOS CLI tool, no JS environment.

The following error will be presented when attempting to read an unsupported JSON file:

Unable to read /Users/lnatan/Desktop/Code/Detox/detox/test/detox.config.js: The data couldn’t be read because it isn’t in the correct format. The config file must be in JSON format. See “detox recorder --help” for usage.

1.0.150 out with the error above.

Hi everyone,

Were you able to resolve this issue?