Skip to content

Commit 622cd71

Browse files
committed
added test and recursive remove certPath
1 parent 23e1033 commit 622cd71

4 files changed

Lines changed: 15 additions & 8 deletions

File tree

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"main": "./lib/index.js",
66
"scripts": {
77
"build": "npx tsc",
8+
"test": "mocha --require ts-node/register -p test/plugin.spec.js --exit --timeout 260000",
89
"prepublish": "npx tsc",
910
"lint": "eslint '**/*.js' --fix",
1011
"prettier": "prettier '**/*.js' --write --single-quote",

src/utils/proxy.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,9 @@ export async function setupProxyServer(
133133
}
134134

135135
export async function cleanUpProxyServer(proxy: Proxy) {
136-
proxy.stop();
137-
fs.rmdirSync(proxy.getCertificatePath());
136+
await proxy.stop();
137+
// @ts-ignore
138+
fs.rmdirSync(proxy.getCertificatePath(), { recursive: true, force: true });
138139
}
139140

140141
function prepareCertificate(sessionId: string) {

test/plugin.spec.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { remote } from 'webdriverio';
22
import { API_DEMOS_APK_PATH as apidemosApp } from 'android-apidemos';
3+
import { expect } from 'chai';
34

45
const APPIUM_HOST = '127.0.0.1';
56
const APPIUM_PORT = 4723;
@@ -12,10 +13,9 @@ const WDIO_PARAMS = {
1213
};
1314
const capabilities = {
1415
platformName: 'Android',
15-
'appium:automationName': 'espresso',
16+
'appium:automationName': 'UIAutomator2',
1617
'appium:app': apidemosApp,
17-
'appium:forceEspressoRebuild': false,
18-
'appium:showGradleLog': true,
18+
'appium:intercept': true,
1919
};
2020
let driver;
2121
describe('Plugin Test', () => {
@@ -24,9 +24,14 @@ describe('Plugin Test', () => {
2424
});
2525

2626
it('Vertical swipe test', async () => {
27-
await driver.$('~Animation');
27+
const mockId = await driver.execute('interceptor: addMock', {
28+
config: {
29+
url: 'https://jsonplaceholder.typicode.com/todos/1',
30+
},
31+
})
32+
expect(mockId).to.not.be.null
2833
});
2934
afterEach(async () => {
30-
await driver.quit();
35+
await driver.deleteSession();
3136
});
3237
});

0 commit comments

Comments
 (0)