Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(config): external configuration files #2050

Merged
merged 10 commits into from May 25, 2020
Merged

Conversation

noomorph
Copy link
Collaborator

@noomorph noomorph commented May 9, 2020

Resolves #901.

Description:

  1. Makes both parameters optional in detox.init(config[, userParams]) signature.

a. Renames config to configOverride. Speaking lodash language, we deep-merge: _.merge(configFromFile, configOverride). Also, userParams parameter is redundant, since you can tweak its behavior via the first configOverride parameter, or right in the config file. Below is an example for sake of the demonstration:

await detox.init({
  selectedConfiguration: process.env.platform === 'android' ? 'android.emulator' : 'ios.simulator',
  artifacts: { rootDir: '.artifacts' },
  behavior: {
    init: { exposeGlobals: false, reinstallApp: false, launchApp: false },
    cleanup: { shutdownDevice: true },
  },
});
  1. Speaking of the aforementioned configFromFile variable, it represents Detox configuration object, imported either from .detoxrc, .detoxrc.json, .detoxrc.js, detox.config.json, detox.config.js, package.json (detox section) in the current working directory, or from process.env.configPath (--config-path CLI argument) path override. If you are using detox-cli, you will have to specify --config-path path/to/.detoxrc parameter to pass it explicitly to mocha or jest runner.

Acknowledgements:

Thanks to @Debens and @oreporan for their early work on this feature. It took long to implement this feature, though the path we walked wasn't short and easy either - there were many configuration refactors preceding it. 🤔

@coveralls
Copy link

coveralls commented May 22, 2020

Pull Request Test Coverage Report for Build 2170

  • 130 of 130 (100.0%) changed or added relevant lines in 13 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.4%) to 77.381%

Totals Coverage Status
Change from base Build 1193: 0.4%
Covered Lines: 3266
Relevant Lines: 3936

💛 - Coveralls

@noomorph noomorph marked this pull request as ready for review May 22, 2020 17:46
@noomorph noomorph requested a review from rotemmiz as a code owner May 22, 2020 17:46
@noomorph noomorph force-pushed the feat/external-config branch 4 times, most recently from e2bfb28 to a6ae396 Compare May 25, 2020 14:46
@noomorph noomorph force-pushed the feat/external-config branch 6 times, most recently from 33e2ecf to cde4934 Compare May 25, 2020 16:03
@noomorph noomorph merged commit 08e6931 into master May 25, 2020
@noomorph noomorph deleted the feat/external-config branch May 25, 2020 17:13
@lock lock bot locked as resolved and limited conversation to collaborators Jun 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

point to a single configuration file
4 participants