From 8d0ae3d97fcead2b84afe6a8c9c8b386f9e639df Mon Sep 17 00:00:00 2001 From: Yaroslav Serhieiev Date: Tue, 16 Apr 2019 12:01:23 +0300 Subject: [PATCH 01/10] feat: undeprecate 'specs' property in package.json --- detox/local-cli/test.js | 42 ++++++++++--------- detox/local-cli/utils/collectExtraArgs.js | 13 ++++-- detox/local-cli/utils/deprecation.js | 10 +++++ detox/package.json | 1 + docs/Guide.Migration.md | 49 ++++++++++++++++------- docs/Troubleshooting.RunningTests.md | 35 ++++++++++++---- 6 files changed, 105 insertions(+), 45 deletions(-) diff --git a/detox/local-cli/test.js b/detox/local-cli/test.js index 16f6d6ff8a..524808c81e 100644 --- a/detox/local-cli/test.js +++ b/detox/local-cli/test.js @@ -8,7 +8,7 @@ const DetoxConfigError = require('../src/errors/DetoxConfigError'); const log = require('../src/utils/logger').child({ __filename }); const {getDetoxSection, getDefaultConfiguration, getConfigurationByKey} = require('./utils/configurationUtils'); -const {coerceDeprecation, migrationGuideUrl} = require('./utils/deprecation'); +const {coerceDeprecation, printFileDeprecationWarning} = require('./utils/deprecation'); const shellQuote = require('./utils/shellQuote'); module.exports.command = 'test'; @@ -137,16 +137,12 @@ module.exports.handler = async function test(program) { const config = getDetoxSection(); - let testFolder = getConfigFor(['file', 'specs'], 'e2e'); - testFolder = testFolder && `"${testFolder}"`; - - if (testFolder && !program.file && !program.specs) { - log.warn('Deprecation warning: "file" and "specs" support will be dropped in the next Detox version.'); - log.warn(`Please edit your package.json according to the migration guide: ${migrationGuideUrl} `); + if (!program.file && config.file) { + printFileDeprecationWarning(config.file); } - const runner = getConfigFor(['test-runner'], 'mocha'); - const runnerConfig = getConfigFor(['runner-config'], getDefaultRunnerConfig()); + const runner = getConfigFor('test-runner') || 'mocha'; + const runnerConfig = getConfigFor('runner-config') || getDefaultRunnerConfig(); const currentConfiguration = getConfigurationByKey(program.configuration); if (!currentConfiguration.type) { @@ -168,17 +164,14 @@ module.exports.handler = async function test(program) { } } - function getConfigFor(keys, fallback) { + function getConfigFor(...keys) { for (const key of keys) { - const camel = _.camelCase(key); - const result = program[key] || config[camel] || config[key]; + const result = program[key] || config[_.camelCase(key)] || config[key]; - if (result != null) { + if (result) { return result; } } - - return fallback; } function hasCustomValue(key) { @@ -188,6 +181,18 @@ module.exports.handler = async function test(program) { return (value !== metadata.default); } + function getPassthroughArguments() { + const args = collectExtraArgs(process.argv.slice(3)); + + const hasFolders = args.some(arg => arg && !arg.startsWith('-')); + if (hasFolders) { + return args; + } + + const fallbackTestFolder = `"${getConfigFor('file', 'specs') || 'e2e'}"`; + return args.concat(fallbackTestFolder); + } + function runMocha() { if (program.workers !== 1) { log.warn('Can not use -w, --workers. Parallel test execution is only supported with iOS and Jest'); @@ -210,8 +215,7 @@ module.exports.handler = async function test(program) { (hasCustomValue('record-videos') ? `--record-videos ${program.recordVideos}` : ''), (program.artifactsLocation ? `--artifacts-location "${program.artifactsLocation}"` : ''), (program.deviceName ? `--device-name "${program.deviceName}"` : ''), - testFolder, - collectExtraArgs(process.argv.slice(3)), + ...getPassthroughArguments(), ]).join(' '); log.info(command); @@ -230,8 +234,7 @@ module.exports.handler = async function test(program) { (program.noColor ? ' --no-color' : ''), `--maxWorkers=${program.workers}`, (platform ? shellQuote(`--testNamePattern=^((?!${getPlatformSpecificString()}).)*$`) : ''), - testFolder, - collectExtraArgs(process.argv.slice(3)), + ...getPassthroughArguments(), ]).join(' '); const detoxEnvironmentVariables = _.pick(program, [ @@ -297,6 +300,5 @@ module.exports.handler = async function test(program) { fs.writeFileSync(lockFilePath, '[]'); } - run(); }; diff --git a/detox/local-cli/utils/collectExtraArgs.js b/detox/local-cli/utils/collectExtraArgs.js index 4a3f2e176c..4c01026f4c 100644 --- a/detox/local-cli/utils/collectExtraArgs.js +++ b/detox/local-cli/utils/collectExtraArgs.js @@ -23,7 +23,11 @@ function collectBlacklistedArgs(builder) { function configureCollectExtraArgs(builder) { const blacklistedArgs = collectBlacklistedArgs(builder); - return function collectExtraArgs(argv) { + /*** + * @param {Object} argv + * @returns {string[]} + */ + function collectExtraArgs(argv) { const parsed = parseArgv(argv, { configuration: { 'boolean-negation': false, @@ -41,11 +45,12 @@ function configureCollectExtraArgs(builder) { return value === true ? `--${key}` : `--${key} ${value}`; }) .concat(parsed['_']) - .value() - .join(' '); + .value(); return passthrough; - }; + } + + return collectExtraArgs; } module.exports = configureCollectExtraArgs; diff --git a/detox/local-cli/utils/deprecation.js b/detox/local-cli/utils/deprecation.js index 1f728c7cd5..fa1b06a162 100644 --- a/detox/local-cli/utils/deprecation.js +++ b/detox/local-cli/utils/deprecation.js @@ -1,3 +1,4 @@ +const chalk = require('chalk'); const log = require('../../src/utils/logger').child({ __filename }); const migrationGuideUrl = 'https://wix.to/I0DOAK0'; @@ -10,7 +11,16 @@ function coerceDeprecation(option) { }; } +function printFileDeprecationWarning(file) { + log.warn('Deprecated: "file" option in "detox" section of package.json won\'t be supported in the next Detox version.\n'); + console.log(` "detox": {`); + console.log(chalk.red(`- "file": ${JSON.stringify(file)},`)); + console.log(chalk.green(`+ "specs": ${JSON.stringify(file)},\n`)); + log.warn(`Please rename it to "specs", as demonstrated above.`); +} + module.exports = { coerceDeprecation, migrationGuideUrl, + printFileDeprecationWarning, }; diff --git a/detox/package.json b/detox/package.json index 63a497373a..f78970738f 100644 --- a/detox/package.json +++ b/detox/package.json @@ -39,6 +39,7 @@ "dependencies": { "bunyan": "^1.8.12", "bunyan-debug-stream": "^1.1.0", + "chalk": "^2.4.2", "child-process-promise": "^2.2.0", "fs-extra": "^4.0.2", "get-port": "^2.1.0", diff --git a/docs/Guide.Migration.md b/docs/Guide.Migration.md index fbba77718e..692ddd392b 100644 --- a/docs/Guide.Migration.md +++ b/docs/Guide.Migration.md @@ -5,6 +5,25 @@ title: Migration Guide We are improving detox API as we go along, sometimes these changes require us to break the API in order for it to make more sense. These migration guides refer to breaking changes. +## Migrating from Detox 12.3.x to 12.4.0 + +The deprecation of `"specs"` (in `package.json`) introduced in 12.1.0 is **no longer relevant**. +It is valid now, like it was before, but from now on the semantics has been slightly changed - +it acts like a fallback for the default root for your Detox e2e specs, in cases when +you don't specify it explicitly, e.g.: + +```sh +detox test # translates to: mocha <...args> e2e +detox test e2e/01.sanity.test.js # translates to: mocha <...args> e2e/01.sanity.test.js +``` + +Previously, it used to work like: + +```sh +detox test # translates to: mocha <...args> e2e +detox test e2e/01.sanity.test.js # translates to: mocha <...args> e2e e2e/01.sanity.test.js +``` + ## Migrating from Detox 12.0.x to 12.1.x This is not a breaking change yet, but starting from `detox@12.1.0` you'll start seeing warnings like: @@ -17,6 +36,22 @@ WARN: [test.js] Please edit your package.json according to the migration guide: In the next major version `--file` and `--specs` will be treated as unknown arguments and therefore passed as-is to your appropriate test runner. +So, if you have been using CLI arguments like `--file e2e` or +`--specs e2e`, please drop the preceding `--file` and `--specs`, so that: + +``` +detox test --file e2e/01.sanity.test.js +``` + +becomes: + +``` +detox test e2e/01.sanity.test.js +``` + +**UPDATE:** It was decided not to deprecate `"specs"` in `package.json`, so the text belove +is not relevant to a large extent. Please ignore. + To get rid of this warning: * find `"specs"` or `"file"` entry in your project's `package.json` and empty it (e.g. `"e2e"` ⟶ `""`); @@ -62,20 +97,6 @@ in `package.json`, then please add it temporarily like this: } ``` -Last, but not least, if you have been using CLI arguments like -`--file e2e` or `--specs e2e`, please drop the preceding -`--file` and `--specs`, so that: - -``` -detox test --specs e2e -``` - -becomes: - -``` -detox test e2e -``` - The idea in the example above is to pass `e2e` straight to `mocha` or `jest` as a path to the folder with Detox tests, without extra preprocessing from Detox CLI side. diff --git a/docs/Troubleshooting.RunningTests.md b/docs/Troubleshooting.RunningTests.md index e506d7ff0b..f282d893d7 100644 --- a/docs/Troubleshooting.RunningTests.md +++ b/docs/Troubleshooting.RunningTests.md @@ -158,17 +158,38 @@ detox[4498] INFO: [test.js] node_modules/.bin/mocha --opts e2e/mocha.opts --con error: unknown option `--configuration' ``` -**Solution:** In `detox@11.1.0` such options as `--file` and `--specs` were -deprecated in favor of straightforward passing command line arguments to test -runners. Since `mocha` does not search for test files recursively in the -current working directory by default, you have to pass the path to your e2e -tests folder manually: +**Solution:** Upgrade to `detox@12.4.0`. Alternatively, you can try the solutions below, +described right after the explanation. + +In `detox@12.1.0` there was a premature deprecation of `"specs"` property in +detox section of `package.json`. It appeared inconvenient for anyone who +prefers terse commands like `detox test` over verbose `detox test e2e`. Starting +from `detox@12.4.0`, `"specs"` property acts like a fallback if a specific +test folder has not been specified. + +If you are using `detox@12.x.x` and cannot upgrade to the latest, you can +pass the path to your e2e tests folder manually: ``` -detox test ./your-e2e-tests-folder +detox test +``` + +The problem itself stems from the fact that `mocha` does not search for test files +recursively in the current working directory by default, contrary to Jest. + +After you upgrade, you can specify default path to your end-to-end tests folder +in `package.json` without getting any deprecation warnings: + +```json +{ + "detox": { + "specs": "your-e2e-tests-folder" + } +} ``` -See [the migration guide](Guide.Migration.md#migrating-from-detox-110x-to-111x) for more details. +If your e2e tests are located at the default path (`e2e`), then you don't need +to add `"specs"` property explicitly.
From 94c3cbcc826ac31b8fe6ce9d24e772603806f213 Mon Sep 17 00:00:00 2001 From: Yaroslav Serhieiev Date: Tue, 16 Apr 2019 12:07:05 +0300 Subject: [PATCH 02/10] code: updated places in the demo projects --- detox/local-cli/init.js | 2 -- detox/test/package.json | 1 - docs/Troubleshooting.RunningTests.md | 16 +++++++++------- examples/demo-native-ios/package.json | 1 - examples/demo-react-native-jest/package.json | 1 - examples/demo-react-native/package.json | 1 - scripts/demo-projects.android.sh | 2 +- 7 files changed, 10 insertions(+), 14 deletions(-) diff --git a/detox/local-cli/init.js b/detox/local-cli/init.js index 39ef915539..c73fefe03a 100644 --- a/detox/local-cli/init.js +++ b/detox/local-cli/init.js @@ -91,11 +91,9 @@ function parsePackageJson(filepath) { function patchPackageJson(packageJson, runnerName) { _.set(packageJson, ['detox', 'test-runner'], runnerName); - _.set(packageJson, ['detox', 'specs'], ""); log.info(PREFIX, 'Patched ./package.json with commands:'); log.info(PREFIX, `_.set(packageJson, ['detox', 'test-runner'], "${runnerName}")`); - log.info(PREFIX, `_.set(packageJson, ['detox', 'specs'], "")`); } function savePackageJson(filepath, json) { diff --git a/detox/test/package.json b/detox/test/package.json index 52c071cb99..3883643e26 100644 --- a/detox/test/package.json +++ b/detox/test/package.json @@ -26,7 +26,6 @@ "mocha": "^5.0.0" }, "detox": { - "specs": "e2e", "test-runner": "mocha", "__session": { "server": "ws://localhost:8099", diff --git a/docs/Troubleshooting.RunningTests.md b/docs/Troubleshooting.RunningTests.md index f282d893d7..2d2918b576 100644 --- a/docs/Troubleshooting.RunningTests.md +++ b/docs/Troubleshooting.RunningTests.md @@ -168,17 +168,19 @@ from `detox@12.4.0`, `"specs"` property acts like a fallback if a specific test folder has not been specified. If you are using `detox@12.x.x` and cannot upgrade to the latest, you can -pass the path to your e2e tests folder manually: +still pass the path to your e2e tests folder manually: ``` detox test ``` -The problem itself stems from the fact that `mocha` does not search for test files -recursively in the current working directory by default, contrary to Jest. +The problem with `unknown option --configuration` stems from the fact +that `mocha` does not search for test files recursively in the current +working directory by default, contrary to Jest. -After you upgrade, you can specify default path to your end-to-end tests folder -in `package.json` without getting any deprecation warnings: +After you upgrade to `12.4.0` or a more recent version, you can specify +default path to your end-to-end tests folder in `package.json` +without getting any deprecation warnings: ```json { @@ -188,8 +190,8 @@ in `package.json` without getting any deprecation warnings: } ``` -If your e2e tests are located at the default path (`e2e`), then you don't need -to add `"specs"` property explicitly. +Please mind that if your e2e tests are located at the default path (`e2e`), +then you don't need to add `"specs"` property explicitly to `package.json`.
diff --git a/examples/demo-native-ios/package.json b/examples/demo-native-ios/package.json index 6a295323eb..22ac38d352 100644 --- a/examples/demo-native-ios/package.json +++ b/examples/demo-native-ios/package.json @@ -7,7 +7,6 @@ "mocha": "^4.0.0" }, "detox": { - "specs": "", "configurations": { "ios.sim.release": { "binaryPath": "build/Build/Products/Release-iphonesimulator/NativeExample.app", diff --git a/examples/demo-react-native-jest/package.json b/examples/demo-react-native-jest/package.json index ab157de811..db5eefe59b 100644 --- a/examples/demo-react-native-jest/package.json +++ b/examples/demo-react-native-jest/package.json @@ -19,7 +19,6 @@ "react-test-renderer": "16.0.0-beta.5" }, "detox": { - "specs": "", "test-runner": "jest", "configurations": { "ios.sim.release": { diff --git a/examples/demo-react-native/package.json b/examples/demo-react-native/package.json index a8c409c114..49681f376e 100644 --- a/examples/demo-react-native/package.json +++ b/examples/demo-react-native/package.json @@ -14,7 +14,6 @@ "mocha": "^4.0.1" }, "detox": { - "specs": "", "test-runner": "mocha", "runner-config": "e2e/mocha.opts", "configurations": { diff --git a/scripts/demo-projects.android.sh b/scripts/demo-projects.android.sh index b28e196154..be307875dd 100755 --- a/scripts/demo-projects.android.sh +++ b/scripts/demo-projects.android.sh @@ -5,7 +5,7 @@ source $(dirname "$0")/demo-projects.sh pushd examples/demo-react-native run_f "detox build -c android.emu.release" run_f "detox test -c android.emu.release" -run_f "detox test -c android.emu.release --specs e2eExplicitRequire --runner-config e2eExplicitRequire/mocha.opts" +run_f "detox test e2eExplicitRequire -c android.emu.release --runner-config e2eExplicitRequire/mocha.opts" popd pushd examples/demo-react-native-jest From a90677b8996af677d774c84cbfffd8277417239b Mon Sep 17 00:00:00 2001 From: Yaroslav Serhieiev Date: Tue, 16 Apr 2019 12:25:50 +0300 Subject: [PATCH 03/10] docs: remove unrelevant parts --- docs/Guide.Migration.md | 49 +++++++++-------------------------------- 1 file changed, 10 insertions(+), 39 deletions(-) diff --git a/docs/Guide.Migration.md b/docs/Guide.Migration.md index 692ddd392b..03ff687f4d 100644 --- a/docs/Guide.Migration.md +++ b/docs/Guide.Migration.md @@ -49,15 +49,15 @@ becomes: detox test e2e/01.sanity.test.js ``` -**UPDATE:** It was decided not to deprecate `"specs"` in `package.json`, so the text belove +**UPDATE:** It was decided not to deprecate `"specs"` in `package.json`, so the text below is not relevant to a large extent. Please ignore. -To get rid of this warning: +~To get rid of this warning:~ -* find `"specs"` or `"file"` entry in your project's `package.json` and empty it (e.g. `"e2e"` ⟶ `""`); -* update your `detox test` scripts — make sure they have an explicit path to your Detox tests folder, e.g. `detox test e2e`. +* ~find `"specs"` or `"file"` entry in your project's `package.json` and empty it (e.g. `"e2e"` ⟶ `""`);~ +* ~update your `detox test` scripts — make sure they have an explicit path to your Detox tests folder, e.g. `detox test e2e`.~ -For example, if it were a `package.json` before: +~For example, if it were a `package.json` before:~ ```json { @@ -71,7 +71,7 @@ For example, if it were a `package.json` before: } ``` -Then this is how it should look like afterwards: +~Then this is how it should look like afterwards:~ ```json { @@ -85,11 +85,11 @@ Then this is how it should look like afterwards: } ``` -Notice that we appended `e2e` to the `e2e:ios` test script and -emptied `"specs"` property in `detox` configuration. +~Notice that we appended `e2e` to the `e2e:ios` test script and +emptied `"specs"` property in `detox` configuration.~ -In a case if you had no `"specs"` property in your `detox` configuration -in `package.json`, then please add it temporarily like this: +~In a case if you had no `"specs"` property in your `detox` configuration +in `package.json`, then please add it temporarily like this:~ ```json { @@ -97,35 +97,6 @@ in `package.json`, then please add it temporarily like this: } ``` -The idea in the example above is to pass `e2e` straight to `mocha` or `jest` as -a path to the folder with Detox tests, without extra preprocessing from Detox CLI side. - -> For the curious ones, who want to know more why we should use an empty string -(`""`) instead of deleting `"specs"` and `"file"` from `package.json`, here is -the explanation. This seemingly weird step is motivated by backward compatibility -with the previous versions of Detox. -> -> So far, before `detox@12.1.0`, absence of -`file` and `specs` properties implied a default test folder value (`"e2e"`). -> In other words: - -```js -const testFolder = config.file || config.specs || "e2e"; -``` - -> In order not to break the existing logic but to introduce the deprecation, -the check for the `e2e` placeholder assignment became narrower yet remaining valid: - -```js -let testFolder = config.file || config.specs; -if (testFolder == null) { // that's why you should change it to an empty string, "" - testFolder = "e2e"; // otherwise, if it is null or undefined, then we save backward compatibility -} -if (testFolder) { printDeprecationWarning(); } -``` - -> As it can be seen above, this move allows to track if you followed the migration guide or not. - ## Migrating from Detox 11.0.1 to 12.0.0 The new version explicity requires **Xcode 10.1 or higher** in order to run tests on iOS ([#1229](https://github.com/wix/Detox/issues/1229)). From e308edca1a1fca7025fedf76e534f4779096f6d3 Mon Sep 17 00:00:00 2001 From: Yaroslav Serhieiev Date: Tue, 16 Apr 2019 12:26:21 +0300 Subject: [PATCH 04/10] docs: fix typo --- docs/Guide.Migration.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/Guide.Migration.md b/docs/Guide.Migration.md index 03ff687f4d..7b2f3243c7 100644 --- a/docs/Guide.Migration.md +++ b/docs/Guide.Migration.md @@ -9,7 +9,7 @@ We are improving detox API as we go along, sometimes these changes require us to The deprecation of `"specs"` (in `package.json`) introduced in 12.1.0 is **no longer relevant**. It is valid now, like it was before, but from now on the semantics has been slightly changed - -it acts like a fallback for the default root for your Detox e2e specs, in cases when +it acts as a fallback for the default root for your Detox e2e specs, in cases when you don't specify it explicitly, e.g.: ```sh From 7f97fcbc33b041b695fb98be0650cce4b2dbd863 Mon Sep 17 00:00:00 2001 From: Yaroslav Serhieiev Date: Tue, 16 Apr 2019 12:29:22 +0300 Subject: [PATCH 05/10] docs: improvement --- docs/Guide.Migration.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/docs/Guide.Migration.md b/docs/Guide.Migration.md index 7b2f3243c7..aaac0fff8f 100644 --- a/docs/Guide.Migration.md +++ b/docs/Guide.Migration.md @@ -29,12 +29,14 @@ detox test e2e/01.sanity.test.js # translates to: mocha <...args> e2e e2e/01.sa This is not a breaking change yet, but starting from `detox@12.1.0` you'll start seeing warnings like: ``` -WARN: [test.js] Deprecation warning: "file" and "specs" support will be dropped in the next Detox version. -WARN: [test.js] Please edit your package.json according to the migration guide: https://wix.to/I0DOAK0 +detox[21201] WARN: [deprecation.js] Beware: -f, --file will be removed in the next version of Detox. +detox[21201] WARN: [deprecation.js] See the migration guide: https://wix.to/I0DOAK0 ``` In the next major version `--file` and `--specs` will be treated as unknown arguments -and therefore passed as-is to your appropriate test runner. +and therefore passed as-is to your appropriate test runner. That allows to avoid name +conflict with the respective `--file` option in Mocha runner itself and other potential +collisions. So, if you have been using CLI arguments like `--file e2e` or `--specs e2e`, please drop the preceding `--file` and `--specs`, so that: @@ -50,7 +52,7 @@ detox test e2e/01.sanity.test.js ``` **UPDATE:** It was decided not to deprecate `"specs"` in `package.json`, so the text below -is not relevant to a large extent. Please ignore. +is not relevant to a large extent. Please ignore the guide below. ~To get rid of this warning:~ From 4e866c97af2f81109c43ba1e3e1c8fe08c09c1b3 Mon Sep 17 00:00:00 2001 From: Yaroslav Serhieiev Date: Tue, 16 Apr 2019 12:36:33 +0300 Subject: [PATCH 06/10] ci: remove explicit e2e path from test scripts --- detox/test/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/detox/test/package.json b/detox/test/package.json index 3883643e26..d3c13290a7 100644 --- a/detox/test/package.json +++ b/detox/test/package.json @@ -6,8 +6,8 @@ "test": ":", "packager": "react-native start", "detox-server": "detox run-server", - "e2e:ios": "detox test e2e --configuration ios.sim.release --debug-synchronization --take-screenshots all --record-logs all", - "e2e:android": "detox test e2e --configuration android.emu.release --take-screenshots all --record-logs all", + "e2e:ios": "detox test --configuration ios.sim.release --debug-synchronization --take-screenshots all --record-logs all", + "e2e:android": "detox test --configuration android.emu.release --take-screenshots all --record-logs all", "build:ios": "detox build --configuration ios.sim.release", "build:android": "detox build --configuration android.emu.release", "verify-artifacts:ios": "jest ./scripts/verify_artifacts_are_not_missing.ios.test.js --testEnvironment node", From f48380661979b790323a9cf16a2528c2617bc90d Mon Sep 17 00:00:00 2001 From: Yaroslav Serhieiev Date: Wed, 17 Apr 2019 09:22:28 +0300 Subject: [PATCH 07/10] docs: refine the troubleshooting guide --- docs/Troubleshooting.RunningTests.md | 50 +++++++++++++--------------- 1 file changed, 24 insertions(+), 26 deletions(-) diff --git a/docs/Troubleshooting.RunningTests.md b/docs/Troubleshooting.RunningTests.md index 2d2918b576..44a590be33 100644 --- a/docs/Troubleshooting.RunningTests.md +++ b/docs/Troubleshooting.RunningTests.md @@ -158,36 +158,34 @@ detox[4498] INFO: [test.js] node_modules/.bin/mocha --opts e2e/mocha.opts --con error: unknown option `--configuration' ``` -**Solution:** Upgrade to `detox@12.4.0`. Alternatively, you can try the solutions below, -described right after the explanation. - -In `detox@12.1.0` there was a premature deprecation of `"specs"` property in -detox section of `package.json`. It appeared inconvenient for anyone who -prefers terse commands like `detox test` over verbose `detox test e2e`. Starting -from `detox@12.4.0`, `"specs"` property acts like a fallback if a specific -test folder has not been specified. - -If you are using `detox@12.x.x` and cannot upgrade to the latest, you can -still pass the path to your e2e tests folder manually: +**Solution:** Upgrade to `detox@^12.4.0` and `mocha@^6.1.3`. +That weird error has been spotted in older versions of `mocha` (including 5.2.0) +and fixed since 6.0.0. In fact, it conceals the genuine error: ``` -detox test +Error: No test files found ``` -The problem with `unknown option --configuration` stems from the fact -that `mocha` does not search for test files recursively in the current -working directory by default, contrary to Jest. - -After you upgrade to `12.4.0` or a more recent version, you can specify -default path to your end-to-end tests folder in `package.json` -without getting any deprecation warnings: - -```json -{ - "detox": { - "specs": "your-e2e-tests-folder" - } -} +If the error appeared after running a short command like `detox test`, +please try out `detox test e2e` (in other words, append the path to your +end-to-end tests folder) - and if that fixes the error, then you deal the +bug in the question and upgrading `detox` and `mocha` should help. + +Here's why you need to upgrade to `detox@12.4.0`. In `12.1.0` there was a +premature deprecation of `"specs"` property in detox section of `package.json`. +The deprecation was revoked in `detox@12.4.0`, and since then `"specs"` property +acts as a fallback if a test folder has not been specified explicitly. + +After you upgrade, you can configure the default path to your end-to-end tests folder +in `package.json` (no deprecation warnings starting from `12.4.0`), as shown below: + +```diff + { + "detox": { +- "specs": "", ++ "specs": "your-e2e-tests-folder", + } + } ``` Please mind that if your e2e tests are located at the default path (`e2e`), From b2ced86fd7dad9d986b5b1fbf36d8feada48d808 Mon Sep 17 00:00:00 2001 From: Yaroslav Serhieiev Date: Thu, 18 Apr 2019 08:49:29 +0300 Subject: [PATCH 08/10] docs: update link --- docs/Guide.Migration.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/Guide.Migration.md b/docs/Guide.Migration.md index aaac0fff8f..4c7be25c37 100644 --- a/docs/Guide.Migration.md +++ b/docs/Guide.Migration.md @@ -30,7 +30,8 @@ This is not a breaking change yet, but starting from `detox@12.1.0` you'll start ``` detox[21201] WARN: [deprecation.js] Beware: -f, --file will be removed in the next version of Detox. -detox[21201] WARN: [deprecation.js] See the migration guide: https://wix.to/I0DOAK0 +detox[21201] WARN: [deprecation.js] See the migration guide: +https://github.com/wix/Detox/blob/master/docs/Guide.Migration.md#migrating-from-detox-120x-to-121x ``` In the next major version `--file` and `--specs` will be treated as unknown arguments From 16dbe479e56cab5f1b693fa54bf09dbef2b3b97f Mon Sep 17 00:00:00 2001 From: Yaroslav Serhieiev Date: Thu, 18 Apr 2019 08:50:58 +0300 Subject: [PATCH 09/10] privacy: address shortener link concern --- detox/local-cli/utils/deprecation.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/detox/local-cli/utils/deprecation.js b/detox/local-cli/utils/deprecation.js index fa1b06a162..4afa7928d1 100644 --- a/detox/local-cli/utils/deprecation.js +++ b/detox/local-cli/utils/deprecation.js @@ -1,11 +1,11 @@ const chalk = require('chalk'); const log = require('../../src/utils/logger').child({ __filename }); -const migrationGuideUrl = 'https://wix.to/I0DOAK0'; +const migrationGuideUrl = 'https://github.com/wix/Detox/blob/master/docs/Guide.Migration.md#migrating-from-detox-120x-to-121x'; function coerceDeprecation(option) { return function coerceDeprecationFn(value) { log.warn(`Beware: ${option} will be removed in the next version of Detox.`); - log.warn(`See the migration guide: ${migrationGuideUrl}`); + log.warn(`See the migration guide:\n${migrationGuideUrl} `); return value; }; From f4500983f5dad1ba2af053370d970838b11670ec Mon Sep 17 00:00:00 2001 From: Yaroslav Serhieiev Date: Thu, 18 Apr 2019 10:10:52 +0300 Subject: [PATCH 10/10] docs: emphasized buggy behavior in 12.1 - 12.3 --- docs/Guide.Migration.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/Guide.Migration.md b/docs/Guide.Migration.md index 4c7be25c37..237021c931 100644 --- a/docs/Guide.Migration.md +++ b/docs/Guide.Migration.md @@ -17,7 +17,7 @@ detox test # translates to: mocha <...args> e2e detox test e2e/01.sanity.test.js # translates to: mocha <...args> e2e/01.sanity.test.js ``` -Previously, it used to work like: +Between 12.1.x and 12.3.x, it was buggy and used to work like this: ```sh detox test # translates to: mocha <...args> e2e