Skip to content

Commit

Permalink
chore: remove deprecated [userParams] arg from detox.init()
Browse files Browse the repository at this point in the history
BREAKING: might affect users who override
DetoxCircusEnvironment#detoxInit protected method
  • Loading branch information
noomorph committed Apr 21, 2022
1 parent f6ff666 commit 729c4a2
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 81 deletions.
21 changes: 1 addition & 20 deletions detox/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ declare global {
* await detox.init();
* });
*/
init(configOverride?: Partial<DetoxConfig>, options?: DetoxInitOptions): Promise<void>;
init(configOverride?: Partial<DetoxConfig>): Promise<void>;

beforeEach(...args: any[]): Promise<void>;

Expand All @@ -330,25 +330,6 @@ declare global {
hook(event: 'UNSAFE_configReady', listener: (config: unknown) => void): void;
}

interface DetoxInitOptions {
/**
* By default, Detox exports `device`, `expect`, `element`, `by` and `waitFor`
* as global variables. If you want to control their initialization manually,
* set this property to `false`.
*
* This is useful when during E2E tests you also need to run regular expectations
* in Node.js. Jest's `expect` for instance, will not be overridden by Detox when
* this option is used.
*/
initGlobals?: boolean;
/**
* By default, `await detox.init()` will uninstall and install the app.
* If you wish to reuse the existing app for a faster run, set the property to
* `false`.
*/
reuse?: boolean;
}

type Point2D = {
x: number,
y: number,
Expand Down
12 changes: 0 additions & 12 deletions detox/src/configuration/composeBehaviorConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@ const _ = require('lodash');
* @param {*} cliConfig
* @param {Detox.DetoxConfig} globalConfig
* @param {Detox.DetoxConfigurationOverrides} localConfig
* @param {Detox.DetoxInitOptions} userParams
*/
function composeBehaviorConfig({
cliConfig,
globalConfig,
localConfig,
userParams
}) {
return _.chain({})
.defaultsDeep(
Expand All @@ -23,12 +21,6 @@ function composeBehaviorConfig({
shutdownDevice: cliConfig.cleanup ? true : undefined,
},
},
userParams && {
init: {
exposeGlobals: userParams.initGlobals,
reinstallApp: negateDefined(userParams.reuse),
},
},
localConfig.behavior,
globalConfig.behavior,
{
Expand All @@ -50,8 +42,4 @@ function composeBehaviorConfig({
.value();
}

function negateDefined(x) {
return x !== undefined ? !x : undefined;
}

module.exports = composeBehaviorConfig;
42 changes: 0 additions & 42 deletions detox/src/configuration/composeBehaviorConfig.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,48 +92,6 @@ describe('composeBehaviorConfig', () => {

expect(actual).toEqual(expected);
});

describe('if user params is set', () => {
beforeEach(() => {
userParams = {
initGlobals: false,
reuse: false,
};
});

it('should override the defaults from local config', () => {
expect(composed()).toEqual({
init: {
exposeGlobals: false,
reinstallApp: true,
},
launchApp: 'auto',
cleanup: {
shutdownDevice: false,
}
});
});

describe('if cli args are set', () => {
beforeEach(() => {
cliConfig.reuse = true;
cliConfig.cleanup = true;
});

it('should override the user params', () => {
expect(composed()).toEqual({
init: {
exposeGlobals: false,
reinstallApp: false,
},
launchApp: 'auto',
cleanup: {
shutdownDevice: true,
}
});
});
});
});
});
});
});
4 changes: 1 addition & 3 deletions detox/src/configuration/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ const hooks = {

async function composeDetoxConfig({
cwd = process.cwd(),
argv,
argv = undefined,
override,
userParams,
}) {
const errorComposer = new DetoxConfigErrorComposer();
const cliConfig = collectCliConfig({ argv });
Expand Down Expand Up @@ -84,7 +83,6 @@ async function composeDetoxConfig({
const behaviorConfig = composeBehaviorConfig({
globalConfig,
localConfig,
userParams,
cliConfig,
});

Expand Down
5 changes: 1 addition & 4 deletions detox/src/configuration/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,6 @@ describe('composeDetoxConfig', () => {
'record-logs': 'all',
'runner-config': 'e2e/jest.config.js',
},
userParams: {
initGlobals: false,
},
override: {
artifacts: {
pathBuilder: class {
Expand Down Expand Up @@ -101,7 +98,7 @@ describe('composeDetoxConfig', () => {
},
behaviorConfig: {
init: {
exposeGlobals: false,
exposeGlobals: true,
reinstallApp: false,
},
cleanup: {
Expand Down

0 comments on commit 729c4a2

Please sign in to comment.