fix(doctor): use
MODIFY
packages/doctor/package.json
packages/doctor/package.json
"yargs": "^17.0.0"
},
"devDependencies": {
- "@appium/gulp-plugins": "^5.1.1"
+ "@appium/gulp-plugins": "^5.1.1",
+ "@appium/test-support": "^1.3.3"
},
"engines": {
"node": ">=10",

MODIFY
packages/doctor/test/android-specs.js
packages/doctor/test/android-specs.js
@@ -6,7 +6,7 @@ import * as adb from 'appium-adb';
import * as utils from '../lib/utils';
import * as tp from 'teen_process';
import chai from 'chai';
-import { withMocks, stubEnv } from 'appium-test-support';
+import { withMocks, stubEnv } from '@appium/test-support';
import B from 'bluebird';
import {removeColors} from './helper';

MODIFY
packages/doctor/test/demo-specs.js
packages/doctor/test/demo-specs.js
@@ -8,7 +8,7 @@ import * as tp from 'teen_process';
import * as prompt from '../lib/prompt';
import log from '../lib/logger';
import { FixSkippedError } from '../lib/doctor';
-import { withMocks, withSandbox, stubLog } from 'appium-test-support';
+import { withMocks, withSandbox, stubLog } from '@appium/test-support';
import B from 'bluebird';

MODIFY
packages/doctor/test/dev-specs.js
packages/doctor/test/dev-specs.js
@@ -4,7 +4,7 @@ import { BinaryIsInPathCheck, AndroidSdkExists } from '../lib/dev';
import { fs } from 'appium-support';
import * as tp from 'teen_process';
import chai from 'chai';
-import { withMocks, stubEnv } from 'appium-test-support';
+import { withMocks, stubEnv } from '@appium/test-support';
import B from 'bluebird';
import { removeColors } from './helper';

MODIFY
packages/doctor/test/doctor-specs.js
packages/doctor/test/doctor-specs.js
import { Doctor, DoctorCheck, FixSkippedError } from '../lib/doctor';
import chai from 'chai';
-import { withSandbox, stubLog } from 'appium-test-support';
+import { withSandbox, stubLog } from '@appium/test-support';
import log from '../lib/logger';
import B from 'bluebird';

MODIFY
packages/doctor/test/general-specs.js
packages/doctor/test/general-specs.js
@@ -7,7 +7,7 @@ import * as utils from '../lib/utils';
import NodeDetector from '../lib/node-detector';
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
-import { withMocks } from 'appium-test-support';
+import { withMocks } from '@appium/test-support';
import B from 'bluebird';
import { removeColors } from './helper';

MODIFY
packages/doctor/test/ios-specs.js
packages/doctor/test/ios-specs.js
@@ -14,7 +14,7 @@ import log from '../lib/logger';
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import B from 'bluebird';
-import { withMocks, withSandbox, stubLog } from 'appium-test-support';
+import { withMocks, withSandbox, stubLog } from '@appium/test-support';
import {removeColors} from './helper';
chai.should();
@@ -28,12 +28,12 @@ describe('ios', function () {
});
it('diagnose - success', async function () {
// xcrun
- mocks.tp.expects('exec').once().returns(
- B.resolve({stdout: 'usage: simctl [--set <path>] [--profiles <path>] <subcommand> ...', stderr: ''}));
+ mocks.tp.expects('exec').once().resolves(
+ {stdout: 'usage: simctl [--set <path>] [--profiles <path>] <subcommand> ...', stderr: ''});
// xcode-select
mocks.tp.expects('exec').once().returns(
B.resolve({stdout: '/a/b/c/d\n', stderr: ''}));
- mocks.fs.expects('exists').once().returns(B.resolve(true));
+ mocks.fs.expects('exists').once().resolves(true);
(await check.diagnose()).should.deep.equal({
ok: true,
optional: false,
@@ -46,7 +46,7 @@ describe('ios', function () {
mocks.tp.expects('exec').once().returns(
B.resolve({stdout: 'usage: simctl [--set <path>] [--profiles <path>] <subcommand> ...', stderr: ''}));
// xcode-select
- mocks.tp.expects('exec').once().returns(B.reject(new Error('Something wrong!')));
+ mocks.tp.expects('exec').once().rejects(new Error('Something wrong!'));
(await check.diagnose()).should.deep.equal({
ok: false,
optional: false,
@@ -61,7 +61,7 @@ describe('ios', function () {
// xcode-select
mocks.tp.expects('exec').once().returns(
B.resolve({stdout: '/a/b/c/d\n', stderr: ''}));
- mocks.fs.expects('exists').once().returns(B.resolve(false));
+ mocks.fs.expects('exists').once().resolves(false);
(await check.diagnose()).should.deep.equal({
ok: false,
optional: false,
@@ -71,7 +71,7 @@ describe('ios', function () {
});
it('diagnose - failure - xcrun does not work', async function () {
// xcrun
- mocks.tp.expects('exec').once().returns(B.reject(new Error('xcrun: error: unable to find utility "simctl", not a developer tool or in PATH')));
+ mocks.tp.expects('exec').once().rejects(new Error('xcrun: error: unable to find utility "simctl", not a developer tool or in PATH'));
// no xcode-select
(await check.diagnose()).should.deep.equal({
ok: false,
@@ -121,7 +121,7 @@ describe('ios', function () {
let logStub = stubLog(S.sandbox, log, {stripColors: true});
S.mocks.tp.expects('exec').once().returns(
B.resolve({stdout: '', stderr: ''}));
- S.mocks.prompter.expects('fixIt').once().returns(B.resolve('yes'));
+ S.mocks.prompter.expects('fixIt').once().resolves('yes');
await check.fix();
S.verify();
logStub.output.should.equal([
@@ -131,7 +131,7 @@ describe('ios', function () {
it('fix - no', async function () {
let logStub = stubLog(S.sandbox, log, {stripColors: true});
S.mocks.tp.expects('exec').never();
- S.mocks.prompter.expects('fixIt').once().returns(B.resolve('no'));
+ S.mocks.prompter.expects('fixIt').once().resolves('no');
await check.fix().should.be.rejectedWith(FixSkippedError);
S.verify();
logStub.output.should.equal([
@@ -145,7 +145,7 @@ describe('ios', function () {
it('fix - yes', async function () {
let logStub = stubLog(S.sandbox, log, {stripColors: true});
S.mocks.utils.expects('authorizeIos').once();
- S.mocks.prompter.expects('fixIt').once().returns(B.resolve('yes'));
+ S.mocks.prompter.expects('fixIt').once().resolves('yes');
await fixes.authorizeIosFix();
S.verify();
logStub.output.should.equal([
@@ -155,7 +155,7 @@ describe('ios', function () {
it('fix - no', async function () {
let logStub = stubLog(S.sandbox, log, {stripColors: true});
S.mocks.utils.expects('authorizeIos').never();
- S.mocks.prompter.expects('fixIt').once().returns(B.resolve('no'));
+ S.mocks.prompter.expects('fixIt').once().resolves('no');
await fixes.authorizeIosFix().should.be.rejectedWith(FixSkippedError);
S.verify();
logStub.output.should.equal([
@@ -180,7 +180,7 @@ describe('ios', function () {
mocks.verify();
});
it('diagnose - failure - DevToolsSecurity crash', async function () {
- mocks.tp.expects('exec').once().returns(B.reject(new Error('Something wrong!')));
+ mocks.tp.expects('exec').once().rejects(new Error('Something wrong!'));
(await check.diagnose()).should.deep.equal({
ok: false,
optional: false,
@@ -220,7 +220,7 @@ describe('ios', function () {
mocks.verify();
});
it('diagnose - failure', async function () {
- mocks.tp.expects('exec').once().returns(B.reject(new Error('Oh No!')));
+ mocks.tp.expects('exec').once().rejects(new Error('Oh No!'));
(await check.diagnose()).should.deep.equal({
ok: false,
optional: false,
@@ -240,7 +240,7 @@ describe('ios', function () {
check.autofix.should.not.be.ok;
});
it('diagnose - success', async function () {
- mocks.CarthageDetector.expects('detect').once().returns(B.resolve('/usr/local/bin/carthage'));
+ mocks.CarthageDetector.expects('detect').once().resolves('/usr/local/bin/carthage');
mocks.tp.expects('exec').once().returns(
B.resolve({stdout: 'Please update to the latest Carthage version: 0.33.0. You currently are on 0.32.0\n0.32.0\n', stderr: ''}));
(await check.diagnose()).should.deep.equal({
@@ -251,7 +251,7 @@ describe('ios', function () {
mocks.verify();
});
it('diagnose - success - one line carthage version', async function () {
- mocks.CarthageDetector.expects('detect').once().returns(B.resolve('/usr/local/bin/carthage'));
+ mocks.CarthageDetector.expects('detect').once().resolves('/usr/local/bin/carthage');
mocks.tp.expects('exec').once().returns(
B.resolve({stdout: '0.32.0\n', stderr: ''}));
(await check.diagnose()).should.deep.equal({
@@ -262,7 +262,7 @@ describe('ios', function () {
mocks.verify();
});
it('diagnose - success - but error happens', async function () {
- mocks.CarthageDetector.expects('detect').once().returns(B.resolve('/usr/local/bin/carthage'));
+ mocks.CarthageDetector.expects('detect').once().resolves('/usr/local/bin/carthage');
mocks.tp.expects('exec').once().throws(new Error());
(await check.diagnose()).should.deep.equal({
ok: true,
@@ -272,7 +272,7 @@ describe('ios', function () {
mocks.verify();
});
it('diagnose - failure', async function () {
- mocks.CarthageDetector.expects('detect').once().returns(B.resolve(null));
+ mocks.CarthageDetector.expects('detect').once().resolves(null);
(await check.diagnose()).should.deep.equal({
ok: false,
optional: false,

MODIFY
packages/doctor/test/node-detector-specs.js
packages/doctor/test/node-detector-specs.js
@@ -5,7 +5,7 @@ import { fs, system } from 'appium-support';
import * as tp from 'teen_process';
import NodeDetector from '../lib/node-detector';
import B from 'bluebird';
-import { withSandbox } from 'appium-test-support';
+import { withSandbox } from '@appium/test-support';
import { EOL } from 'os';

MODIFY
packages/doctor/test/prompt-specs.js
packages/doctor/test/prompt-specs.js
import chai from 'chai';
import { fixIt, clear } from '../lib/prompt';
import { inquirer } from '../lib/utils';
-import { withMocks } from 'appium-test-support';
+import { withMocks } from '@appium/test-support';
import B from 'bluebird';

fix(doctor): use @appium/test-support