Skip to content

Commit

Permalink
Merge branch 'master' into element-take-screenshot
Browse files Browse the repository at this point in the history
  • Loading branch information
noomorph committed May 25, 2021
2 parents e05793c + a4b370e commit 8c1b00a
Show file tree
Hide file tree
Showing 232 changed files with 1,152 additions and 917 deletions.
2 changes: 1 addition & 1 deletion detox-cli/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function log(msg) {
function main([_$0, _detox, ...cliArgs]) {
const [command] = cliArgs;

if (!isInstalledGlobally) {
if (process.platform !== 'win32' && !isInstalledGlobally) {
log('Error: "detox-cli" package is not meant to be installed locally, exiting...');
log('HINT: Remove the local installation and reinstall it globally:');
log(' npm uninstall detox-cli');
Expand Down
2 changes: 1 addition & 1 deletion detox-cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "detox-cli",
"version": "18.13.0",
"version": "18.14.1",
"description": "Optional wrapper for Detox CLI, meant to be installed globally",
"main": "cli.js",
"scripts": {
Expand Down
1 change: 1 addition & 0 deletions detox/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
src/android/espressoapi/**/*.js
73 changes: 63 additions & 10 deletions detox/.eslintrc
Original file line number Diff line number Diff line change
@@ -1,24 +1,77 @@
{
"env": {
"node": true,
"jest": true
"jest": true,
"node": true
},
"plugins": ["node"],
"extends": ["plugin:node/recommended"],
"extends": [
"eslint:recommended",
"plugin:import/recommended",
"plugin:node/recommended"
],
"globals": {
"fail": true,
"fail": true
},
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module",
"ecmaFeatures": {
"experimentalObjectRestSpread": true
}
},
"ecmaVersion": 2018,
"sourceType": "module"
},
"plugins": [
"import",
"node",
"no-only-tests"
],
"rules": {
"array-bracket-spacing": [
"error",
"never"
],
"computed-property-spacing": [
"error",
"never"
],
"import/order": [
"error",
{
"alphabetize": {
"order": "asc"
},
"newlines-between": "always"
}
],
"no-case-declarations": "off",
"no-debugger": "error",
"no-undef": "warn",
"no-empty": "off",
"no-mixed-spaces-and-tabs": "error",
"node/no-unpublished-require": "warn"
"no-multiple-empty-lines": [
"error",
{
"max": 2,
"maxBOF": 1
}
],
"no-only-tests/no-only-tests": "error",
"no-undef": "warn",
"no-unused-vars": [
"warn",
{
"argsIgnorePattern": "^_"
}
],
"node/no-unpublished-require": "warn",
"object-curly-spacing": [
"error",
"always"
],
"semi": [
"error",
"always"
],
"quotes": ["error", "single", {
"avoidEscape": true,
"allowTemplateLiterals": true
}]
}
}
2 changes: 1 addition & 1 deletion detox/.nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8
12.22.1
4 changes: 3 additions & 1 deletion detox/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "detox",
"description": "E2E tests and automation for mobile",
"version": "18.13.0",
"version": "18.14.1",
"bin": {
"detox": "local-cli/cli.js"
},
Expand Down Expand Up @@ -33,6 +33,8 @@
"@types/child-process-promise": "^2.2.1",
"@types/ws": "^7.4.0",
"eslint": "^4.11.0",
"eslint-plugin-import": "^2.23.3",
"eslint-plugin-no-only-tests": "^2.6.0",
"eslint-plugin-node": "^6.0.1",
"jest": "^26.5.0",
"jest-circus": "^26.5.2",
Expand Down
10 changes: 6 additions & 4 deletions detox/runners/jest-circus/environment.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
const _ = require('lodash');
const NodeEnvironment = require('jest-environment-node');
const _ = require('lodash');

const DetoxError = require('../../src/errors/DetoxError');
const Timer = require('../../src/utils/Timer');

const DetoxCoreListener = require('./listeners/DetoxCoreListener');
const DetoxInitErrorListener = require('./listeners/DetoxInitErrorListener');
const assertJestCircus26 = require('./utils/assertJestCircus26');
const assertExistingContext = require('./utils/assertExistingContext');
const assertJestCircus26 = require('./utils/assertJestCircus26');
const wrapErrorWithNoopLifecycle = require('./utils/wrapErrorWithNoopLifecycle');
const DetoxError = require('../../src/errors/DetoxError');
const Timer = require('../../src/utils/Timer');

const SYNC_CIRCUS_EVENTS = new Set([
'start_describe_definition',
Expand Down
5 changes: 3 additions & 2 deletions detox/runners/jest-circus/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const DetoxCircusEnvironment = require('./environment');
const WorkerAssignReporterCircus = require('../jest/WorkerAssignReporterCircus');
const SpecReporterCircus = require('../jest/SpecReporterCircus');
const WorkerAssignReporterCircus = require('../jest/WorkerAssignReporterCircus');

const DetoxCircusEnvironment = require('./environment');

module.exports = {
DetoxCircusEnvironment,
Expand Down
11 changes: 6 additions & 5 deletions detox/runners/jest-circus/listeners/DetoxCoreListener.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const { RETRY_TIMES } = require('jest-circus/build/types');
const _ = require('lodash');
const {getFullTestName, hasTimedOut} = require('../../jest/utils');

const {
onRunDescribeStart,
onTestStart,
Expand All @@ -8,7 +9,7 @@ const {
onTestDone,
onRunDescribeFinish,
} = require('../../integration').lifecycle;
const { RETRY_TIMES } = require('jest-circus/build/types');
const { getFullTestName, hasTimedOut } = require('../../jest/utils');

class DetoxCoreListener {
constructor({ detox, env }) {
Expand All @@ -20,7 +21,7 @@ class DetoxCoreListener {
}

_getTestInvocations(test) {
const {DETOX_RERUN_INDEX} = process.env;
const { DETOX_RERUN_INDEX } = process.env;

if (!isNaN(DETOX_RERUN_INDEX)) {
return Number(DETOX_RERUN_INDEX) * this._testRunTimes + test.invocations;
Expand All @@ -29,13 +30,13 @@ class DetoxCoreListener {
}
}

async run_describe_start({describeBlock: {name, children}}) {
async run_describe_start({ describeBlock: { name, children } }) {
if (children.length) {
await this.detox[onRunDescribeStart]({ name });
}
}

async run_describe_finish({describeBlock: {name, children}}) {
async run_describe_finish({ describeBlock: { name, children } }) {
if (children.length) {
await this.detox[onRunDescribeFinish]({ name });
}
Expand Down
2 changes: 1 addition & 1 deletion detox/runners/jest-circus/utils/assertExistingContext.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { filterErrorStack } = require('../../../src/utils/errorUtils');
const { DetoxRuntimeError } = require('../../../src/errors/DetoxRuntimeError');
const { filterErrorStack } = require('../../../src/utils/errorUtils');

function findUserConstructor() {
let wasInBaseClass = false;
Expand Down
1 change: 1 addition & 0 deletions detox/runners/jest-circus/utils/assertJestCircus26.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const fs = require('fs');
const path = require('path');

const DetoxRuntimeError = require('../../../src/errors/DetoxRuntimeError');

function assertJestCircus26(config) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const _ = require('lodash');

const lifecycleSymbols = require('../../integration').lifecycle;

function wrapErrorWithNoopLifecycle(error) {
Expand Down
9 changes: 5 additions & 4 deletions detox/runners/jest/DetoxAdapterCircus.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const _ = require('lodash');

const DetoxAdapter = require('./DetoxAdapterImpl');
const { getFullTestName, hasTimedOut } = require('./utils');

Expand All @@ -24,12 +25,12 @@ class DetoxAdapterCircus {
await this._adapter.afterAll();
}

async run_describe_start({describeBlock: {name, children}}, state) {
if (children.length) await this._adapter.suiteStart({name});
async run_describe_start({ describeBlock: { name, children } }, state) {
if (children.length) await this._adapter.suiteStart({ name });
}

async run_describe_finish({describeBlock: {name, children}}, state) {
if (children.length) await this._adapter.suiteEnd({name});
async run_describe_finish({ describeBlock: { name, children } }, state) {
if (children.length) await this._adapter.suiteEnd({ name });
}

test_start(event) {
Expand Down
12 changes: 6 additions & 6 deletions detox/runners/jest/DetoxAdapterImpl.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,23 @@ class DetoxAdapterImpl {
await this._flush();
}

async suiteStart({name}) {
this._enqueue(() => this.detox.suiteStart({name}));
async suiteStart({ name }) {
this._enqueue(() => this.detox.suiteStart({ name }));
}

async suiteEnd({name}) {
this._enqueue(() => this.detox.suiteEnd({name}));
async suiteEnd({ name }) {
this._enqueue(() => this.detox.suiteEnd({ name }));
}

testStart({title, fullName, status}) {
testStart({ title, fullName, status }) {
this._currentTest = {
title,
fullName,
status,
};
}

testComplete({status, timedOut}) {
testComplete({ status, timedOut }) {
if (this._currentTest) {
const _test = {
...this._currentTest,
Expand Down
5 changes: 3 additions & 2 deletions detox/runners/jest/DetoxAdapterJasmine.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const _ = require('lodash');

const DetoxAdapter = require('./DetoxAdapterImpl');

class DetoxAdapterJasmine /* extends JasmineReporter */ {
Expand All @@ -24,11 +25,11 @@ class DetoxAdapterJasmine /* extends JasmineReporter */ {
}

async suiteStarted(result) {
await this._adapter.suiteStart({name: result.description});
await this._adapter.suiteStart({ name: result.description });
}

async suiteDone(result) {
await this._adapter.suiteEnd({name: result.description});
await this._adapter.suiteEnd({ name: result.description });
}

specStarted(result) {
Expand Down
3 changes: 2 additions & 1 deletion detox/runners/jest/DetoxStreamlineJestReporter.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const {VerboseReporter: JestVerboseReporter} = require('@jest/reporters'); // eslint-disable-line node/no-extraneous-require
const { VerboseReporter: JestVerboseReporter } = require('@jest/reporters'); // eslint-disable-line node/no-extraneous-require

const DetoxRuntimeError = require('../../src/errors/DetoxRuntimeError');

class DetoxStreamlineJestReporter extends JestVerboseReporter {
Expand Down
1 change: 1 addition & 0 deletions detox/runners/jest/FailingTestsReporter.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const path = require('path');

const { saveLastFailedTests } = require('../../src/utils/lastFailedTests');

class FailingTestsReporter {
Expand Down
1 change: 1 addition & 0 deletions detox/runners/jest/SpecReporterCircus.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const argparse = require('../../src/utils/argparse');

const SpecReporter = require('./SpecReporterImpl');

class SpecReporterCircus {
Expand Down
20 changes: 11 additions & 9 deletions detox/runners/jest/SpecReporterImpl.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
const chalk = require('chalk').default;
const { traceln } = require('./utils/stdout');

const log = require('../../src/utils/logger').child();

const { traceln } = require('./utils/stdout');

const RESULT_SKIPPED = chalk.yellow('SKIPPED');
const RESULT_FAILED = chalk.red('FAIL');
const RESULT_PENDING = chalk.yellow('PENDING');
Expand All @@ -14,8 +16,8 @@ class SpecReporter {
this._suitesDesc = '';
}

onSuiteStart({description}) {
this._suites.push({description});
onSuiteStart({ description }) {
this._suites.push({ description });
this._regenerateSuitesDesc();
}

Expand All @@ -28,11 +30,11 @@ class SpecReporter {
}
}

onTestStart({description, invocations = 1}) {
this._traceTest({description, invocations});
onTestStart({ description, invocations = 1 }) {
this._traceTest({ description, invocations });
}

onTestEnd({description, invocations = 1}, result) {
onTestEnd({ description, invocations = 1 }, result) {
let status;
switch (result) {
case 'skipped': status = RESULT_SKIPPED; break;
Expand All @@ -41,7 +43,7 @@ class SpecReporter {
case 'success': status = RESULT_SUCCESS; break;
default: status = RESULT_OTHER; break;
}
this._traceTest({description, invocations}, status);
this._traceTest({ description, invocations }, status);
}

_regenerateSuitesDesc() {
Expand All @@ -57,12 +59,12 @@ class SpecReporter {
this._suitesDesc = chalk.bold.white(this._suitesDesc);
}

_traceTest({description, invocations}, _status = undefined) {
_traceTest({ description, invocations }, _status = undefined) {
const testDescription = chalk.gray(description);
const retriesDescription = (invocations > 1) ? chalk.gray(` [Retry #${invocations - 1}]`) : '';
const status = chalk.gray(_status ? ` [${_status}]` : '');
const desc = this._suitesDesc + testDescription + retriesDescription + status;
log.info({event: 'SPEC_STATE_CHANGE'}, desc);
log.info({ event: 'SPEC_STATE_CHANGE' }, desc);
}
}

Expand Down
5 changes: 3 additions & 2 deletions detox/runners/jest/WorkerAssignReporterImpl.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const _ = require('lodash');
const chalk = require('chalk').default;
const _ = require('lodash');

const log = require('../../src/utils/logger').child();

class WorkerAssignReporterImpl {
Expand All @@ -13,7 +14,7 @@ class WorkerAssignReporterImpl {
? chalk.redBright('undefined')
: chalk.blueBright(deviceName);

log.info({event: 'WORKER_ASSIGN'}, `${chalk.whiteBright(workerName)} is assigned to ${formattedDeviceName}`);
log.info({ event: 'WORKER_ASSIGN' }, `${chalk.whiteBright(workerName)} is assigned to ${formattedDeviceName}`);
}
}

Expand Down
1 change: 1 addition & 0 deletions detox/runners/jest/WorkerAssignReporterJasmine.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const path = require('path');

const WorkerAssignReporter = require('./WorkerAssignReporterImpl');

class WorkerAssignReporterJasmine {
Expand Down
Loading

0 comments on commit 8c1b00a

Please sign in to comment.