Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/wdio-runner' into w…
Browse files Browse the repository at this point in the history
…dio-runner
  • Loading branch information
Othinn committed Jan 9, 2024
2 parents be2119b + 45f5349 commit 4508057
Show file tree
Hide file tree
Showing 3 changed files with 315 additions and 71 deletions.
122 changes: 61 additions & 61 deletions packages/rn-tester-e2e/e2e-config.js
Original file line number Diff line number Diff line change
@@ -1,61 +1,61 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
* @format
*/

const path = require('path');

type Capabilities = {
platformName: 'Android' | 'iOS',
'appium:platformVersion': string,
'appium:deviceName': string,
'appium:app': string,
'appium:automationName': 'UiAutomator2' | 'XCUITest',
'appium:newCommandTimeout'?: number,
};

let capabilities: Capabilities;

const android = {
platformName: 'Android',
'appium:platformVersion': '14.0',
'appium:deviceName': 'Android Emulator',
'appium:app': path.join(process.cwd(), '/apps/rn-tester.apk'),
'appium:automationName': 'UiAutomator2',
'appium:newCommandTimeout': 240,
};

const ios = {
platformName: 'iOS',
'appium:platformVersion': '16.4',
'appium:deviceName': 'iPhone 14',
'appium:automationName': 'XCUITest',
'appium:app': path.join(process.cwd(), '/apps/rn-tester.app'),
};

// check that E2E_DEVICE exists, is a string and its either "ios" or "android"
if (!process.env.E2E_DEVICE) {
throw new Error('E2E_DEVICE environment variable is not defined');
} else if (typeof process.env.E2E_DEVICE !== 'string') {
throw new Error('E2E_DEVICE environment variable is not a string');
} else if (
process.env.E2E_DEVICE !== 'ios' &&
process.env.E2E_DEVICE !== 'android'
) {
throw new Error('E2E_DEVICE environment variable is not "ios" or "android"');
}

if (process.env.E2E_DEVICE === 'android') {
capabilities = android;
}

if (process.env.E2E_DEVICE === 'ios') {
capabilities = ios;
}

export default capabilities;
// /**
// * Copyright (c) Meta Platforms, Inc. and affiliates.
// *
// * This source code is licensed under the MIT license found in the
// * LICENSE file in the root directory of this source tree.
// *
// * @flow
// * @format
// */

// const path = require('path');

// type Capabilities = {
// platformName: 'Android' | 'iOS',
// 'appium:platformVersion': string,
// 'appium:deviceName': string,
// 'appium:app': string,
// 'appium:automationName': 'UiAutomator2' | 'XCUITest',
// 'appium:newCommandTimeout'?: number,
// };

// let capabilities: Capabilities;

// const android = {
// platformName: 'Android',
// 'appium:platformVersion': '14.0',
// 'appium:deviceName': 'Android Emulator',
// 'appium:app': path.join(process.cwd(), '/apps/rn-tester.apk'),
// 'appium:automationName': 'UiAutomator2',
// 'appium:newCommandTimeout': 240,
// };

// const ios = {
// platformName: 'iOS',
// 'appium:platformVersion': '16.4',
// 'appium:deviceName': 'iPhone 14',
// 'appium:automationName': 'XCUITest',
// 'appium:app': path.join(process.cwd(), '/apps/rn-tester.app'),
// };

// // check that E2E_DEVICE exists, is a string and its either "ios" or "android"
// if (!process.env.E2E_DEVICE) {
// throw new Error('E2E_DEVICE environment variable is not defined');
// } else if (typeof process.env.E2E_DEVICE !== 'string') {
// throw new Error('E2E_DEVICE environment variable is not a string');
// } else if (
// process.env.E2E_DEVICE !== 'ios' &&
// process.env.E2E_DEVICE !== 'android'
// ) {
// throw new Error('E2E_DEVICE environment variable is not "ios" or "android"');
// }

// if (process.env.E2E_DEVICE === 'android') {
// capabilities = android;
// }

// if (process.env.E2E_DEVICE === 'ios') {
// capabilities = ios;
// }

// export default capabilities;
20 changes: 10 additions & 10 deletions packages/rn-tester-e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@
"test-e2e-android": "npx wdio wdio.conf.android.js"
},
"devDependencies": {
"eslint": "^8.19.0",
"webdriverio": "^7.32.0",
"@babel/core": "^7.20.0",
"@babel/plugin-transform-flow-strip-types": "^7.20.0",
"@babel/preset-env": "^7.20.0",
"@wdio/appium-service": "^8.10.5",
"@wdio/cli": "^8.10.5",
"@wdio/local-runner": "^8.10.5",
"@wdio/mocha-framework": "8.10.4",
"@wdio/spec-reporter": "8.8.7",
"@babel/register": "^7.20.0",
"@types/mocha": "^10.0.3",
"@wdio/appium-service": "^7.32.0",
"@wdio/cli": "^7.32.0",
"@wdio/local-runner": "^7.32.0",
"@wdio/mocha-framework": "^7.32.0",
"@wdio/spec-reporter": "^7.32.0",
"appium": "2.0.0",
"appium-uiautomator2-driver": "^2.29.0",
"appium-xcuitest-driver": "5.6.0",
"eslint": "^8.23.1",
"ts-node": "^10.9.1",
"typescript": "^5.3.2"
"appium-xcuitest-driver": "^5.6.0"
}
}
244 changes: 244 additions & 0 deletions packages/rn-tester-e2e/wdio.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,244 @@

const path = require('path');
exports.config = {
runner: 'local',
port: 4723,
path: '/',
baseUrl: 'http://localhost',

specs: [
'./tests/specs/components/*.test.js'
],
// Patterns to exclude.
exclude: [
// 'path/to/excluded/files'
],

maxInstances: 1,

//For now ios only
capabilities: [{
platformName: 'iOS',
'appium:platformVersion': '17.0',
'appium:deviceName': 'iPhone 15',
'appium:automationName': 'XCUITest',
'appium:app': path.join(process.cwd(), '/apps/rn-tester.app'),
}],

//
// ===================
// Test Configurations
// ===================
// Define all options that are relevant for the WebdriverIO instance here
//
// Level of logging verbosity: trace | debug | info | warn | error | silent
logLevel: 'debug',
//
// Set specific log levels per logger
// loggers:
// - webdriver, webdriverio
// - @wdio/browserstack-service, @wdio/devtools-service, @wdio/sauce-service
// - @wdio/mocha-framework, @wdio/jasmine-framework
// - @wdio/local-runner
// - @wdio/sumologic-reporter
// - @wdio/cli, @wdio/config, @wdio/utils
// Level of logging verbosity: trace | debug | info | warn | error | silent
// logLevels: {
// webdriver: 'info',
// '@wdio/appium-service': 'info'
// },
//
// If you only want to run your tests until a specific amount of tests have failed use
// bail (default is 0 - don't bail, run all tests).
bail: 0,
//
// Set a base URL in order to shorten url command calls. If your `url` parameter starts
// with `/`, the base url gets prepended, not including the path portion of your baseUrl.
// If your `url` parameter starts without a scheme or `/` (like `some/path`), the base url
// gets prepended directly.
//
// Default timeout for all waitFor* commands.
waitforTimeout: 10000,
//
// Default timeout in milliseconds for request
// if browser driver or grid doesn't send response
connectionRetryTimeout: 120000,
//
// Default request retries count
connectionRetryCount: 3,
services: ['appium'],
appium: {
args: {
address: 'localhost',
port: 4723,
command: 'appium',
debugLogSpacing: true,
logLevel: 'info'
}
},

// Framework you want to run your specs with.
// The following are supported: Mocha, Jasmine, and Cucumber
// see also: https://webdriver.io/docs/frameworks
//
// Make sure you have the wdio adapter package for the specific framework installed
// before running any tests.
framework: 'mocha',
reporters: ['spec'],
mochaOpts: {
ui: 'bdd',
timeout: 60000,
require: ['@babel/register']
},

//
// =====
// Hooks
// =====
// WebdriverIO provides several hooks you can use to interfere with the test process in order to enhance
// it and to build services around it. You can either apply a single function or an array of
// methods to it. If one of them returns with a promise, WebdriverIO will wait until that promise got
// resolved to continue.
/**
* Gets executed once before all workers get launched.
* @param {object} config wdio configuration object
* @param {Array.<Object>} capabilities list of capabilities details
*/
// onPrepare: function (config, capabilities) {
// },
/**
* Gets executed before a worker process is spawned and can be used to initialise specific service
* for that worker as well as modify runtime environments in an async fashion.
* @param {string} cid capability id (e.g 0-0)
* @param {object} caps object containing capabilities for session that will be spawn in the worker
* @param {object} specs specs to be run in the worker process
* @param {object} args object that will be merged with the main configuration once worker is initialized
* @param {object} execArgv list of string arguments passed to the worker process
*/
// onWorkerStart: function (cid, caps, specs, args, execArgv) {
// },
/**
* Gets executed just after a worker process has exited.
* @param {string} cid capability id (e.g 0-0)
* @param {number} exitCode 0 - success, 1 - fail
* @param {object} specs specs to be run in the worker process
* @param {number} retries number of retries used
*/
// onWorkerEnd: function (cid, exitCode, specs, retries) {
// },
/**
* Gets executed just before initialising the webdriver session and test framework. It allows you
* to manipulate configurations depending on the capability or spec.
* @param {object} config wdio configuration object
* @param {Array.<Object>} capabilities list of capabilities details
* @param {Array.<String>} specs List of spec file paths that are to be run
* @param {string} cid worker id (e.g. 0-0)
*/
// beforeSession: function (config, capabilities, specs, cid) {
// },
/**
* Gets executed before test execution begins. At this point you can access to all global
* variables like `browser`. It is the perfect place to define custom commands.
* @param {Array.<Object>} capabilities list of capabilities details
* @param {Array.<String>} specs List of spec file paths that are to be run
* @param {object} browser instance of created browser/device session
*/
// before: function (capabilities, specs) {
// },
/**
* Runs before a WebdriverIO command gets executed.
* @param {string} commandName hook command name
* @param {Array} args arguments that command would receive
*/
// beforeCommand: function (commandName, args) {
// },
/**
* Hook that gets executed before the suite starts
* @param {object} suite suite details
*/
// beforeSuite: function (suite) {
// },
/**
* Function to be executed before a test (in Mocha/Jasmine) starts.
*/
// beforeTest: function (test, context) {
// },
/**
* Hook that gets executed _before_ a hook within the suite starts (e.g. runs before calling
* beforeEach in Mocha)
*/
// beforeHook: function (test, context, hookName) {
// },
/**
* Hook that gets executed _after_ a hook within the suite starts (e.g. runs after calling
* afterEach in Mocha)
*/
// afterHook: function (test, context, { error, result, duration, passed, retries }, hookName) {
// },
/**
* Function to be executed after a test (in Mocha/Jasmine only)
* @param {object} test test object
* @param {object} context scope object the test was executed with
* @param {Error} result.error error object in case the test fails, otherwise `undefined`
* @param {*} result.result return object of test function
* @param {number} result.duration duration of test
* @param {boolean} result.passed true if test has passed, otherwise false
* @param {object} result.retries information about spec related retries, e.g. `{ attempts: 0, limit: 0 }`
*/
afterTest: async function(test, context, { error, result, duration, passed, retries }) {
if (!passed) {
await driver.takeScreenshot();
}
},


/**
* Hook that gets executed after the suite has ended
* @param {object} suite suite details
*/
// afterSuite: function (suite) {
// },
/**
* Runs after a WebdriverIO command gets executed
* @param {string} commandName hook command name
* @param {Array} args arguments that command would receive
* @param {number} result 0 - command success, 1 - command error
* @param {object} error error object if any
*/
// afterCommand: function (commandName, args, result, error) {
// },
/**
* Gets executed after all tests are done. You still have access to all global variables from
* the test.
* @param {number} result 0 - test pass, 1 - test fail
* @param {Array.<Object>} capabilities list of capabilities details
* @param {Array.<String>} specs List of spec file paths that ran
*/
// after: function (result, capabilities, specs) {
// },
/**
* Gets executed right after terminating the webdriver session.
* @param {object} config wdio configuration object
* @param {Array.<Object>} capabilities list of capabilities details
* @param {Array.<String>} specs List of spec file paths that ran
*/
// afterSession: function (config, capabilities, specs) {
// },
/**
* Gets executed after all workers got shut down and the process is about to exit. An error
* thrown in the onComplete hook will result in the test run failing.
* @param {object} exitCode 0 - success, 1 - fail
* @param {object} config wdio configuration object
* @param {Array.<Object>} capabilities list of capabilities details
* @param {<Object>} results object containing test results
*/
// onComplete: function(exitCode, config, capabilities, results) {
// },
/**
* Gets executed when a refresh happens.
* @param {string} oldSessionId session ID of the old session
* @param {string} newSessionId session ID of the new session
*/
// onReload: function(oldSessionId, newSessionId) {
// }
};

0 comments on commit 4508057

Please sign in to comment.