mirror of
https://github.com/appium/appium.git
synced 2026-02-22 11:19:06 -06:00
feat(fake-plugin): use peer deps
BREAKING CHANGE: This now requires a peer dependency on `appium`
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import {logger} from '@appium/support';
|
||||
import {logger} from 'appium/support';
|
||||
|
||||
const log = logger.getLogger('FakePlugin');
|
||||
|
||||
|
||||
@@ -1,14 +1,18 @@
|
||||
// @ts-check
|
||||
/* eslint-disable no-case-declarations */
|
||||
|
||||
import BasePlugin from '@appium/base-plugin';
|
||||
import {BasePlugin} from 'appium/plugin';
|
||||
import B from 'bluebird';
|
||||
|
||||
export default class FakePlugin extends BasePlugin {
|
||||
class FakePlugin extends BasePlugin {
|
||||
async getFakePluginArgs() {
|
||||
await B.delay(1);
|
||||
return this.cliArgs;
|
||||
}
|
||||
|
||||
/**
|
||||
* @type {import('@appium/types').MethodMap<FakePlugin>}
|
||||
*/
|
||||
static newMethodMap = {
|
||||
'/session/:sessionId/fake_data': {
|
||||
GET: {command: 'getFakeSessionData', neverProxy: true},
|
||||
@@ -23,6 +27,7 @@ export default class FakePlugin extends BasePlugin {
|
||||
},
|
||||
};
|
||||
|
||||
/** @type {string?} */
|
||||
static _unexpectedData = null;
|
||||
|
||||
static fakeRoute(req, res) {
|
||||
@@ -33,8 +38,9 @@ export default class FakePlugin extends BasePlugin {
|
||||
res.send(JSON.stringify(FakePlugin._unexpectedData));
|
||||
FakePlugin._unexpectedData = null;
|
||||
}
|
||||
// eslint-disable-next-line require-await
|
||||
static async updateServer(expressApp /*, httpServer*/) {
|
||||
|
||||
// eslint-disable-next-line no-unused-vars,require-await
|
||||
static async updateServer(expressApp, httpServer) {
|
||||
expressApp.all('/fake', FakePlugin.fakeRoute);
|
||||
expressApp.all('/unexpected', FakePlugin.unexpectedData);
|
||||
}
|
||||
@@ -68,9 +74,11 @@ export default class FakePlugin extends BasePlugin {
|
||||
return `<<${handle}>>`;
|
||||
}
|
||||
|
||||
onUnexpectedShutdown(driver, cause) {
|
||||
// eslint-disable-next-line require-await
|
||||
async onUnexpectedShutdown(driver, cause) {
|
||||
FakePlugin._unexpectedData = `Session ended because ${cause}`;
|
||||
}
|
||||
}
|
||||
|
||||
export {FakePlugin};
|
||||
export default FakePlugin;
|
||||
|
||||
@@ -35,6 +35,9 @@
|
||||
"bluebird": "3.7.2",
|
||||
"lodash": "4.17.21"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"appium": "file:../appium"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12",
|
||||
"npm": ">=6"
|
||||
|
||||
@@ -1,19 +1,7 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"outDir": "./build",
|
||||
"paths": {
|
||||
"@appium/base-plugin": ["../base-plugin"],
|
||||
"@appium/support": ["../support"]
|
||||
}
|
||||
"outDir": "build"
|
||||
},
|
||||
"extends": "../../config/tsconfig.base.json",
|
||||
"include": ["lib"],
|
||||
"references": [
|
||||
{
|
||||
"path": "../base-plugin"
|
||||
},
|
||||
{
|
||||
"path": "../support"
|
||||
}
|
||||
]
|
||||
}
|
||||
"extends": "../../config/tsconfig.plugin.json",
|
||||
"include": ["lib"]
|
||||
}
|
||||
Reference in New Issue
Block a user