feat(fake): add unexpected shutdown handler
MODIFY
packages/appium-plugins/packages/fake/lib/plugin.js
packages/appium-plugins/packages/fake/lib/plugin.js
@@ -24,12 +24,20 @@ export default class FakePlugin extends BasePlugin {
},
};
+ static _unexpectedData = null;
+
static fakeRoute (req, res) {
res.send(JSON.stringify({fake: 'fakeResponse'}));
}
+ static unexpectedData (req, res) {
+ res.send(JSON.stringify(FakePlugin._unexpectedData));
+ FakePlugin._unexpectedData = null;
+ }
+
static async updateServer (expressApp/*, httpServer*/) { // eslint-disable-line require-await
expressApp.all('/fake', FakePlugin.fakeRoute);
+ expressApp.all('/unexpected', FakePlugin.unexpectedData);
}
async getPageSource (next, driver, ...args) {
@@ -60,6 +68,10 @@ export default class FakePlugin extends BasePlugin {
const handle = await next();
return `<<${handle}>>`;
}
+
+ onUnexpectedShutdown (driver, cause) {
+ FakePlugin._unexpectedData = `Session ended because ${cause}`;
+ }
}
export { FakePlugin };

feat(fake): add unexpected shutdown handler