Skip to content

Commit

Permalink
refactor: Decouple the module from @appium/gulp-plugins (#538)
Browse files Browse the repository at this point in the history
  • Loading branch information
mykola-mokhnach authored Sep 1, 2022
1 parent e35f1d8 commit 53818f1
Show file tree
Hide file tree
Showing 20 changed files with 98 additions and 112 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
static
coverage
build
3 changes: 0 additions & 3 deletions .eslintrc

This file was deleted.

11 changes: 11 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": "@appium/eslint-config-appium",
"overrides": [
{
"files": "test/**/*.js",
"rules": {
"func-names": "off"
}
}
]
}
7 changes: 4 additions & 3 deletions .github/workflows/publish.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Use Node.js 16.x
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version: 16.x
node-version: lts/*
check-latest: true
- run: npm install
name: Install dependencies
- run: npm test
- run: npm run test
name: Run NPM Test
- run: |
rm -rf package-lock.json
Expand Down
4 changes: 4 additions & 0 deletions .mocharc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
require: ['@babel/register'],
forbidOnly: Boolean(process.env.CI)
};
25 changes: 25 additions & 0 deletions babel.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"presets": [
[
"@babel/preset-env",
{
"targets": {
"node": "14"
},
"shippedProposals": true
}
]
],
"plugins": [
"source-map-support",
"@babel/plugin-transform-runtime"
],
"comments": false,
"sourceMaps": "both",
"env": {
"test": {
"retainLines": true,
"comments": true
}
}
}
6 changes: 2 additions & 4 deletions ci-jobs/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ jobs:
versionSpec: 16.x
- script: npm install
displayName: Install Node dependencies
- script: |
npm install -g appium@next
npm run build
- script: npm run build
displayName: Build
- script: npm test
- script: npm run test
displayName: Run Unit Tests
6 changes: 0 additions & 6 deletions ci-jobs/mochareporters.json

This file was deleted.

15 changes: 0 additions & 15 deletions ci-jobs/nightly.yml

This file was deleted.

14 changes: 6 additions & 8 deletions ci-jobs/pr-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,17 @@ stages:
- task: NodeTool@0
inputs:
versionSpec: $(DEFAULT_NODE_VERSION)
- script: |
npm install -g appium@next
npm run clean
- script: npm install
displayName: Build
- script: npm test
- script: npm run test
displayName: Run Unit Tests

# TODO: Update e2e tests for webdriverio compatibility
- stage: Integration_Tests
jobs:
- template: templates/android-e2e-template.yml
parameters:
script: npx mocha --timeout 6000000 --reporter mocha-multi-reporters --reporter-options configFile=./ci-jobs/mochareporters.json --recursive build/test/functional/driver-e2e-specs.js -g @skip-ci -i --exit
script: npm run e2e-test:driver
sleep: 20
name: sdk30_e2e_tests
vmImage: $(DEFAULT_VM_IMAGE)
Expand All @@ -38,23 +36,23 @@ stages:
NODE_VERSION: $(DEFAULT_NODE_VERSION)
- template: templates/android-e2e-template.yml
parameters:
script: npx mocha --timeout 6000000 --reporter mocha-multi-reporters --reporter-options configFile=./ci-jobs/mochareporters.json --recursive build/test/functional/driver-e2e-specs.js -g @skip-ci -i --exit
script: npm run e2e-test:driver
name: sdk28_e2e_tests
vmImage: $(DEFAULT_VM_IMAGE)
CHROMEDRIVER_VERSION: 2.44
ANDROID_SDK_VERSION: 28
NODE_VERSION: $(DEFAULT_NODE_VERSION)
- template: templates/android-e2e-template.yml
parameters:
script: npx mocha --timeout 6000000 --reporter mocha-multi-reporters --reporter-options configFile=./ci-jobs/mochareporters.json --recursive build/test/functional/driver-e2e-specs.js -g @skip-ci -i --exit
script: npm run e2e-test:driver
name: sdk25_e2e_tests
vmImage: $(DEFAULT_VM_IMAGE)
CHROMEDRIVER_VERSION: 2.28
ANDROID_SDK_VERSION: 25
NODE_VERSION: $(DEFAULT_NODE_VERSION)
- template: templates/android-e2e-template.yml
parameters:
script: npx mocha --timeout 6000000 --reporter mocha-multi-reporters --reporter-options configFile=./ci-jobs/mochareporters.json --recursive build/test/functional/driver-e2e-specs.js -g @skip-ci -i --exit
script: npm run e2e-test:driver
name: sdk23_e2e_tests
vmImage: $(DEFAULT_VM_IMAGE)
CHROMEDRIVER_VERSION: 2.20
Expand Down
14 changes: 0 additions & 14 deletions ci-jobs/real-device-build.yml

This file was deleted.

8 changes: 0 additions & 8 deletions ci-jobs/templates/android-e2e-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ parameters:
name: 'android_e2e_tests'
vmImage: 'macOS-12'
sleep: 1
MOCHA_FILE: 'sdk-$(ANDROID_SDK_VERSION)-test-results.xml'
CHROMEDRIVER_VERSION: 2.44
NODE_VERSION: 16.x
ANDROID_SDK_VERSION: 28
Expand All @@ -18,7 +17,6 @@ jobs:
variables:
CI: true
TERM: dumb
MOCHA_FILE: ${{ parameters.MOCHA_FILE }}
ANDROID_SDK_VERSION: ${{ parameters.ANDROID_SDK_VERSION }}
steps:
- task: NodeTool@0
Expand All @@ -30,8 +28,6 @@ jobs:
displayName: Install Node dependencies
- script: npm install --no-save mjpeg-consumer
displayName: Install MJPEG Consumer
- script: npm test
displayName: NPM Test
- script: $ANDROID_HOME/tools/bin/sdkmanager --list
displayName: List SDKs
- script: bash ci-jobs/scripts/start-emulator.sh
Expand Down Expand Up @@ -69,7 +65,3 @@ jobs:
JAVA_HOME: $(JAVA_HOME_11_X64)
PATH: $(JAVA_HOME_11_X64)/bin:$(PATH)
displayName: Run tests
- task: PublishTestResults@2
condition: always()
inputs:
testResultsFiles: ${{ parameters.MOCHA_FILE }}
12 changes: 0 additions & 12 deletions gulpfile.js

This file was deleted.

62 changes: 33 additions & 29 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"android"
],
"version": "2.4.8",
"author": "appium",
"author": "Appium Contributors",
"license": "Apache-2.0",
"repository": {
"type": "git",
Expand All @@ -17,9 +17,20 @@
"bugs": {
"url": "https://github.com/appium/appium-uiautomator2-driver/issues"
},
"engines": [
"node"
],
"engines": {
"node": ">=14",
"npm": ">=8"
},
"lint-staged": {
"*.js": [
"eslint --fix"
]
},
"prettier": {
"bracketSpacing": false,
"printWidth": 100,
"singleQuote": true
},
"appium": {
"driverName": "uiautomator2",
"automationName": "UiAutomator2",
Expand Down Expand Up @@ -55,48 +66,41 @@
"teen_process": "^2.0.0"
},
"scripts": {
"prepare": "rimraf build && gulp prepublish",
"transpile": "gulp transpile",
"clean": "rm -rf node_modules && rm -f package-lock.json && npm install",
"build": "gulp transpile",
"test": "gulp once",
"e2e-test": "gulp e2e-test",
"watch": "gulp watch",
"mocha": "mocha",
"mocha:parallel": "mocha-parallel-tests",
"coverage": "gulp coveralls",
"lint": "gulp lint",
"lint:fix": "gulp eslint --fix",
"build": "rimraf build && babel --out-dir=build/lib lib && babel --out-dir=build index.js",
"dev": "npm run build -- --watch",
"lint": "eslint .",
"lint:fix": "npm run lint -- --fix",
"precommit-msg": "echo 'Pre-commit checks...' && exit 0",
"e2e": "gulp transpile && mocha -t 6400000 -R spec build/test/functional/**/*-specs.js build/test/functional/*-specs.js",
"e2e:find": "gulp transpile && mocha -t 6400000 -R spec build/test/functional/commands/find/*-specs.js",
"e2e:keyboard": "gulp transpile && mocha -t 6400000 -R spec build/test/functional/commands/keyboard/*-specs.js",
"e2e:commands": "gulp transpile && mocha -t 6400000 -R spec build/test/functional/commands/*-specs.js",
"e2e:testobject": "cross-env TESTOBJECT_E2E_TESTS=true npm run e2e"
"precommit-lint": "lint-staged",
"prepare": "npm run build",
"test": "mocha --exit --timeout 1m \"./test/unit/**/*-specs.js\"",
"e2e-test:driver": "mocha --exit --timeout 10m \"./test/functional/driver-e2e-specs.js\""
},
"pre-commit": [
"precommit-msg",
"test"
"precommit-lint"
],
"peerDependencies": {
"appium": "^2.0.0-beta.40"
},
"devDependencies": {
"@appium/gulp-plugins": "^7.0.0",
"@appium/eslint-config-appium": "^6.0.0",
"@appium/test-support": "^1.0.0",
"@babel/core": "^7.16.0",
"@babel/cli": "^7.18.10",
"@babel/core": "^7.18.10",
"@babel/eslint-parser": "^7.18.9",
"@babel/plugin-transform-runtime": "^7.18.10",
"@babel/preset-env": "^7.18.10",
"@babel/register": "^7.18.9",
"@semantic-release/git": "^10.0.1",
"@xmldom/xmldom": "^0.x",
"android-apidemos": "^4.0.0",
"android-apidemos": "^4.1.1",
"babel-plugin-source-map-support": "^2.2.0",
"chai": "^4.1.0",
"chai-as-promised": "^7.1.1",
"eslint-config-prettier": "^8.5.0",
"gps-demo-app": "^2.1.1",
"gulp": "^4.0.0",
"lint-staged": "^13.0.3",
"mocha": "^10.0.0",
"mocha-junit-reporter": "^2.0.0",
"mocha-multi-reporters": "^1.1.7",
"pngjs": "^6.0.0",
"pre-commit": "^1.2.2",
"rimraf": "^3.0.0",
Expand Down
Binary file added test/functional/assets/gpsDemo-debug.apk
Binary file not shown.
6 changes: 3 additions & 3 deletions test/functional/commands/find/by-image-e2e-specs.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import { initSession, deleteSession } from '../../helpers/session';
chai.should();
chai.use(chaiAsPromised);

const START_IMG = path.resolve('.', 'test', 'functional', 'assets', 'start-button.png');
const STOP_IMG = path.resolve('.', 'test', 'functional', 'assets', 'stop-button.png');
const SQUARES_IMG = path.resolve('.', 'test', 'functional', 'assets', 'checkered-squares.png');
const START_IMG = path.resolve(__dirname, '..', '..', 'assets', 'start-button.png');
const STOP_IMG = path.resolve(__dirname, '..', '..', 'assets', 'stop-button.png');
const SQUARES_IMG = path.resolve(__dirname, '..', '..', 'assets', 'checkered-squares.png');

describe('Find - Image @skip-ci', function () {
let driver;
Expand Down
10 changes: 6 additions & 4 deletions test/functional/desired.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import _ from 'lodash';
import path from 'path';

const uiautomator2ServerLaunchTimeout = (process.env.TRAVIS || process.env.CI) ? 60000 : 20000;
const uiautomator2ServerInstallTimeout = (process.env.TRAVIS || process.env.CI) ? 120000 : 20000;
Expand Down Expand Up @@ -37,18 +38,19 @@ const GENERIC_CAPS = deepFreeze({
});


const apiDemosApp = require.resolve('android-apidemos');
const gpsDemoApp = require('gps-demo-app');
const { API_DEMOS_APK_PATH } = require('android-apidemos');
// http://www.impressive-artworx.de/tutorials/android/gps_tutorial_1.zip
const gpsDemoApp = path.resolve(__dirname, 'assets', 'gpsDemo-debug.apk');

const APIDEMOS_CAPS = amendCapabilities(GENERIC_CAPS, {
'appium:app': apiDemosApp,
'appium:app': API_DEMOS_APK_PATH,
'appium:appPackage': 'io.appium.android.apis',
'appium:appActivity': '.ApiDemos',
'appium:disableWindowAnimation': true,
});

const SCROLL_CAPS = amendCapabilities(GENERIC_CAPS, {
'appium:app': apiDemosApp,
'appium:app': API_DEMOS_APK_PATH,
'appium:appPackage': 'io.appium.android.apis',
'appium:appActivity': '.view.ScrollView2',
});
Expand Down
2 changes: 1 addition & 1 deletion test/unit/commands/general-specs.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import sinon from 'sinon';
import AndroidUiautomator2Driver from '../../..';
import AndroidUiautomator2Driver from '../../../lib/driver';
import ADB from 'appium-adb';

let driver;
Expand Down
2 changes: 1 addition & 1 deletion test/unit/commands/touch-specs.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import AndroidUiautomator2Driver from '../../..';
import AndroidUiautomator2Driver from '../../../lib/driver';
import ADB from 'appium-adb';


Expand Down
2 changes: 1 addition & 1 deletion test/unit/driver-specs.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import AndroidUiautomator2Driver from '../..';
import AndroidUiautomator2Driver from '../../lib/driver';
import sinon from 'sinon';
import path from 'path';
import B from 'bluebird';
Expand Down

0 comments on commit 53818f1

Please sign in to comment.