Get rid of Babel and rewrite @wdio/repl (#5804)

This commit is contained in:
Christian Bromann 2020-09-21 10:54:42 +02:00 committed by GitHub
parent 07c4d4e4d3
commit 6712e310be
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
191 changed files with 3431 additions and 5393 deletions

View file

@ -14,5 +14,5 @@ charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[{.babelrc,.eslintrc,.codeclimate.yml,.travis.yml,**/*.json,.eslintrc.js,.github/**/*.yml}]
[{.travis.yml,**/*.json,.github/**/*.yml}]
indent_size = 2

View file

@ -2,6 +2,5 @@
/packages/**/node_modules
/packages/node_modules
/packages/**/coverage
/tests/typings/**/dist
tests/typings/**/node_modules
/tests/typings
*.d.ts

View file

@ -1,44 +1,44 @@
module.exports = {
extends: [
'eslint:recommended',
'plugin:import/errors',
'plugin:import/warnings'
],
env: {
node: true,
es6: true
},
parser: 'babel-eslint',
parserOptions: {
ecmaVersion: 2016,
sourceType: 'module'
},
rules: {
semi: ['error', 'never'],
quotes: ['error', 'single'],
indent: [2, 4],
root: true,
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint'],
extends: [
'eslint:recommended'
],
env: {
node: true,
es6: true
},
parserOptions: {
ecmaVersion: 2017,
sourceType: 'module'
},
rules: {
semi: ['error', 'never'],
indent: [2, 4],
'import/no-unresolved': [2, { commonjs: true, amd: true }],
'import/named': 2,
'import/namespace': 2,
'import/default': 2,
'import/export': 2,
'no-multiple-empty-lines': [2, {'max': 1, 'maxEOF': 1}],
'array-bracket-spacing': ['error', 'never'],
'brace-style': ['error', '1tbs', { allowSingleLine: true }],
camelcase: ['error', { properties: 'never' }],
'comma-spacing': ['error', { before: false, after: true }],
'no-lonely-if': 'error',
'no-else-return': 'error',
'no-tabs': 'error',
'no-trailing-spaces': ['error', {
skipBlankLines: false,
ignoreComments: false
}],
quotes: ['error', 'single', { avoidEscape: true }],
'unicode-bom': ['error', 'never'],
'object-curly-spacing': ['error', 'always'],
'require-atomic-updates': 0
}
'no-multiple-empty-lines': [2, { 'max': 1, 'maxEOF': 1 }],
'array-bracket-spacing': ['error', 'never'],
'brace-style': ['error', '1tbs', { allowSingleLine: true }],
camelcase: ['error', { properties: 'never' }],
'comma-spacing': ['error', { before: false, after: true }],
'no-lonely-if': 'error',
'no-else-return': 'error',
'no-tabs': 'error',
'no-trailing-spaces': ['error', {
skipBlankLines: false,
ignoreComments: false
}],
quotes: ['error', 'single', { avoidEscape: true }],
'unicode-bom': ['error', 'never'],
'object-curly-spacing': ['error', 'always'],
'require-atomic-updates': 0
},
overrides: [{
files: ['*.ts'],
rules: {
// see https://github.com/typescript-eslint/typescript-eslint/issues/46
'@typescript-eslint/no-unused-vars': [2, { args: 'none' }]
}
}]
}

2
.gitignore vendored
View file

@ -66,8 +66,8 @@ tests/typings/**/dist
/*.js
allure-reporter.d.ts
devtools.d.ts
!babel.config.js
!.eslintrc.js
!jest.config.js
packages/**/package-lock.json
.DS_Store

View file

@ -34,7 +34,7 @@ In order to set up this project and start contributing follow this step by step
* Builds all subpackages via ```npm run build```
As the last step you need to build all sub-packages in order to resolve the internal dependencies. We also have a NPM command for that:
As the last step you need to build all sub-packages in order to resolve the internal dependencies. WebdriverIO uses [TypeScript](https://www.typescriptlang.org/) as compiler. We are currently transitioning to TypeScript so you will see a mixture of normal JS files and TypeScript files.
* Run Tests to ensure that everything is set up correctly
@ -77,13 +77,13 @@ If you only work on a single package you can watch only for that one by calling:
```sh
# e.g. `$ npm run watch:pkg @wdio/runner`
$ npm run watch:pkg <package-name>
$ npm run watch <package-name>
```
It is also a good idea to run jest in watch mode while developing on a single package to see if changes affect any tests:
```sh
$ npx jest ./packages/<package-name>/tests --watch
$ npx jest ./packages/<package-name>/tests --watch --coverageReporters lcov
```
## Create New Package

View file

@ -1,21 +0,0 @@
module.exports = {
presets: [
['@babel/preset-env', {
targets: {
node: 8
}
}]
],
plugins: [
'@babel/plugin-proposal-function-bind',
'@babel/plugin-proposal-class-properties',
'@babel/plugin-proposal-optional-catch-binding'
],
env: {
development: {
sourceMaps: 'inline',
plugins: ['source-map-support']
}
},
comments: false
}

View file

@ -5,5 +5,8 @@ module.exports = {
'<rootDir>/*.test.js'
],
moduleFileExtensions: ['js', 'ts'],
setupFilesAfterEnv: ['./jest.setup.js']
setupFilesAfterEnv: ['./jest.setup.js'],
transform: {
'^.+\\.(ts|js)$': 'ts-jest'
}
}

View file

@ -5,7 +5,6 @@
* $ npm install devtools webdriverio
*
*/
// eslint-disable-next-line import/no-unresolved
const { remote } = require('../../packages/webdriverio')
let browser;

59
jest.config.js Normal file
View file

@ -0,0 +1,59 @@
/**
* workaround for bug
* https://github.com/jsdom/jsdom/issues/2795
* https://github.com/jsdom/jsdom/issues/2961
*/
const SKIPPED_NODE_10_TESTS = process.version.startsWith('v10')
? [
'<rootDir>/packages/webdriverio/tests/commands/browser/newWindow.test.js',
'<rootDir>/packages/webdriverio/tests/commands/element/isFocused.test.js',
'<rootDir>/packages/webdriverio/tests/scripts/resq.test.js',
'<rootDir>/packages/webdriverio/tests/scripts/isFocused.test.js'
]
: []
module.exports = {
testMatch: [
'**/tests/**/*.test.(js|ts)'
],
transform: {
'^.+\\.(ts|js)$': 'ts-jest'
},
testPathIgnorePatterns: [
'<rootDir>/tests/',
'<rootDir>/node_modules/',
...SKIPPED_NODE_10_TESTS
],
collectCoverageFrom: [
'packages/**/src/**/*.js'
],
moduleNameMapper: {
'graceful-fs': '<rootDir>/tests/helpers/fs.js'
},
coverageDirectory: './coverage/',
collectCoverage: true,
coverageThreshold: {
global: {
branches: 95,
functions: 98,
lines: 99,
statements: 98
}
},
testEnvironment: 'node',
coveragePathIgnorePatterns: [
'node_modules/',
'packages/devtools/src/scripts',
'packages/devtools/src/commands',
'packages/webdriverio/src/scripts',
'packages/wdio-devtools-service/src/scripts',
'packages/webdriverio/build',
'packages/webdriver/build',
'packages/wdio-cucumber-framework/tests/fixtures',
'packages/wdio-logger/build',
'packages/wdio-webdriver-mock-service',
'packages/wdio-lambda-runner',
'packages/wdio-smoke-test-reporter',
'packages/wdio-smoke-test-service'
]
}

6794
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -6,8 +6,7 @@
"backport": "node ./scripts/backport.js",
"bootstrap-full": "npm run clean && lerna bootstrap --no-ci && npm run link",
"bootstrap": "run-p clean:* && lerna bootstrap --force-local && npm run link",
"build-full": "lerna run --parallel build",
"build": "npm run clean:build && lerna run --parallel compile && lerna run --parallel copy",
"build": "run-s clean:build compile copy",
"changelog": "node ./scripts/changelog.js",
"ci": "run-s setup-full test test:e2e",
"clean": "run-p clean-full:* clean:*",
@ -19,12 +18,14 @@
"clean:tests": "rimraf tests/typings/**/node_modules tests/typings/**/dist ./coverage",
"clean:cache": "rimraf .eslintcache",
"clean-full:package_modules": "rimraf ./packages/*/node_modules",
"compile": "node ./scripts/build",
"copy": "lerna run --parallel copy",
"generate:typings": "node ./scripts/type-generation/generate-all-typings.js",
"link": "node ./scripts/link",
"release": "NODE_ENV=production npm run setup-full && npm run generate:typings && lerna publish --exact && npm run pushReleaseTag",
"release:next": "npm run release -- --dist-tag next",
"pushReleaseTag": "node ./scripts/pushTags.js",
"setup-full": "run-s bootstrap-full build-full",
"setup-full": "run-s bootstrap-full build",
"setup": "run-s bootstrap build",
"docs": "run-s docs:*",
"docs:setup": "cd ./website && npm install && cd ..",
@ -36,7 +37,7 @@
"test:eslint": "eslint --cache packages examples scripts tests",
"test:typings": "npm run generate:typings && node tests/typings/copy && npm run ts && npm run clean:tests",
"test:coverage": "node --max-old-space-size=8192 ./node_modules/.bin/jest --coverage --logHeapUsage",
"test:smoke": "babel-node ./tests/smoke.runner.js",
"test:smoke": "ts-node ./tests/smoke.runner.js",
"test:e2e": "jest --config e2e/jest.config.js",
"ts": "run-p ts:*",
"ts:sync": "cd tests/typings/sync && tsc --incremental",
@ -57,27 +58,15 @@
"ts:webdriverio-mocha": "cd tests/typings/webdriverio-mocha && tsc --incremental",
"ts:webdriverio-jasmine": "cd tests/typings/webdriverio-jasmine && tsc --incremental",
"ts:webdriverio-reporter": "cd tests/typings/webdriverio-reporter && tsc --incremental",
"watch": "node ./scripts/watch",
"watch:pkg": "lerna exec 'npm run compile -- --watch' --scope",
"watch": "node ./scripts/build --watch",
"version": "npm run changelog && git add CHANGELOG.md"
},
"devDependencies": {
"@babel/cli": "^7.6.2",
"@babel/core": "^7.6.2",
"@babel/node": "^7.6.2",
"@babel/plugin-proposal-class-properties": "^7.5.5",
"@babel/plugin-proposal-function-bind": "^7.2.0",
"@babel/plugin-proposal-optional-catch-binding": "^7.2.0",
"@babel/plugin-syntax-export-default-from": "^7.2.0",
"@babel/preset-env": "^7.6.2",
"@babel/register": "^7.6.2",
"@octokit/rest": "^18.0.0",
"@types/jest": "^26.0.0",
"@typescript-eslint/eslint-plugin": "^4.1.0",
"@typescript-eslint/parser": "^4.1.0",
"aws-sdk": "^2.539.0",
"babel-core": "^6.26.3",
"babel-eslint": "^10.0.3",
"babel-jest": "^26.0.1",
"babel-plugin-source-map-support": "^2.1.1",
"cheerio": "^1.0.0-rc.3",
"codecov": "^3.6.1",
"copyfiles": "^2.1.1",
@ -101,8 +90,9 @@
"rimraf": "^3.0.0",
"sass": "^1.26.5",
"shelljs": "^0.8.3",
"source-map-support": "^0.5.13",
"tempy": "^0.7.0",
"ts-jest": "^26.3.0",
"ts-node": "^9.0.0",
"typescript": "^4.0.2",
"url-join": "^4.0.1"
},
@ -112,51 +102,5 @@
"pre-push": "npm run test:eslint"
}
},
"jest": {
"testMatch": [
"**/tests/**/*.test.js"
],
"testPathIgnorePatterns": [
"<rootDir>/tests/",
"<rootDir>/node_modules/"
],
"collectCoverageFrom": [
"packages/**/src/**/*.js"
],
"moduleNameMapper": {
"graceful-fs": "<rootDir>/tests/helpers/fs.js"
},
"coverageDirectory": "./coverage/",
"collectCoverage": true,
"coverageThreshold": {
"global": {
"branches": 96,
"functions": 98,
"lines": 99,
"statements": 99
}
},
"testEnvironment": "node",
"coveragePathIgnorePatterns": [
"node_modules/",
"packages/devtools/src/scripts",
"packages/devtools/src/commands",
"packages/webdriverio/src/scripts",
"packages/wdio-devtools-service/src/scripts",
"packages/webdriverio/build",
"packages/webdriver/build",
"packages/wdio-cucumber-framework/tests/fixtures",
"packages/wdio-logger/build",
"packages/wdio-webdriver-mock-service",
"packages/wdio-lambda-runner",
"packages/wdio-smoke-test-reporter",
"packages/wdio-smoke-test-service"
]
},
"greenkeeper": {
"lockfiles": {
"outOfRangeUpdatesOnly": true
}
},
"dependencies": {}
}

View file

@ -1,2 +1,4 @@
src
tests
tsconfig.json
tsconfig.prod.json

View file

@ -1 +0,0 @@
message = "devtools: bump version %s"

View file

@ -11,15 +11,6 @@
},
"types": "./devtools.d.ts",
"typeScriptVersion": "3.7.3",
"scripts": {
"tsc": "tsc",
"build": "run-s clean compile",
"clean": "rimraf ./build",
"compile": "babel src/ -d build/ --config-file ../../babel.config.js",
"test": "run-s test:*",
"test:eslint": "eslint src test",
"test:unit": "jest"
},
"repository": {
"type": "git",
"url": "git://github.com/webdriverio/webdriverio.git"

View file

@ -15,7 +15,7 @@ export default async function switchToWindow ({ handle }) {
delete this.currentFrame
this.currentWindowHandle = handle
const page = this.getPageHandle()
page.on('dialog', ::this.dialogHandler)
page.on('dialog', this.dialogHandler.bind(this))
await page.bringToFront()
return handle

View file

@ -0,0 +1,11 @@
{
"extends": "../../tsconfig.prod",
"compilerOptions": {
"baseUrl": ".",
"outDir": "./build",
"rootDir": "./src"
},
"include": [
"src/**/*"
]
}

View file

@ -1 +0,0 @@
message = "eslint-plugin-wdio: bump version %s"

View file

@ -1,2 +1,4 @@
src
tests
tsconfig.json
tsconfig.prod.json

View file

@ -1 +0,0 @@
message = "@wdio/allure-reporter: bump version %s"

View file

@ -10,15 +10,6 @@
"node": ">=10.0.0"
},
"types": "./allure-reporter.d.ts",
"scripts": {
"tsc": "tsc",
"build": "run-s clean compile",
"clean": "rimraf ./build",
"compile": "babel src/ -d build/ --config-file ../../babel.config.js",
"test": "run-s test:*",
"test:eslint": "eslint src test",
"test:unit": "jest"
},
"repository": {
"type": "git",
"url": "git://github.com/webdriverio/webdriverio.git"

View file

@ -0,0 +1,11 @@
{
"extends": "../../tsconfig.prod",
"compilerOptions": {
"baseUrl": ".",
"outDir": "./build",
"rootDir": "./src"
},
"include": [
"src/**/*"
]
}

View file

@ -1,2 +1,4 @@
src
tests
tests
tsconfig.json
tsconfig.prod.json

View file

@ -1 +0,0 @@
message = "wdio-appium-service: bump version %s"

View file

@ -9,15 +9,6 @@
"engines": {
"node": ">=10.0.0"
},
"scripts": {
"tsc": "tsc",
"build": "run-s clean compile",
"clean": "rimraf ./build",
"compile": "babel src/ -d build/ --config-file ../../babel.config.js",
"test": "run-s test:*",
"test:eslint": "eslint src test",
"test:unit": "jest"
},
"repository": {
"type": "git",
"url": "git://github.com/webdriverio/webdriverio.git"

View file

@ -0,0 +1,11 @@
{
"extends": "../../tsconfig.prod",
"compilerOptions": {
"baseUrl": ".",
"outDir": "./build",
"rootDir": "./src"
},
"include": [
"src/**/*"
]
}

View file

@ -1,2 +1,4 @@
src
tests
tests
tsconfig.json
tsconfig.prod.json

View file

@ -1 +0,0 @@
message = "@wdio/applitools-service: bump version %s"

View file

@ -9,15 +9,6 @@
"engines": {
"node": ">=10.0.0"
},
"scripts": {
"tsc": "tsc",
"build": "run-s clean compile",
"clean": "rimraf ./build",
"compile": "babel src/ -d build/ --config-file ../../babel.config.js",
"test": "run-s test:*",
"test:eslint": "eslint src test",
"test:unit": "jest"
},
"repository": {
"type": "git",
"url": "git://github.com/webdriverio/webdriverio.git"

View file

@ -0,0 +1,11 @@
{
"extends": "../../tsconfig.prod",
"compilerOptions": {
"baseUrl": ".",
"outDir": "./build",
"rootDir": "./src"
},
"include": [
"src/**/*"
]
}

View file

@ -1,2 +1,4 @@
src
tests
tsconfig.json
tsconfig.prod.json

View file

@ -1 +0,0 @@
message = "@wdio/browserstack-service: bump version %s"

View file

@ -9,15 +9,6 @@
"engines": {
"node": ">=10.0.0"
},
"scripts": {
"tsc": "tsc",
"build": "run-s clean compile",
"clean": "rimraf ./build",
"compile": "babel src/ -d build/ --config-file ../../babel.config.js",
"test": "run-s test:*",
"test:eslint": "eslint src test",
"test:unit": "jest"
},
"repository": {
"type": "git",
"url": "git://github.com/webdriverio/webdriverio.git"

View file

@ -0,0 +1,11 @@
{
"extends": "../../tsconfig.prod",
"compilerOptions": {
"baseUrl": ".",
"outDir": "./build",
"rootDir": "./src"
},
"include": [
"src/**/*"
]
}

View file

@ -1,2 +1,4 @@
src
tests
tsconfig.json
tsconfig.prod.json

View file

@ -1 +0,0 @@
message = "@wdio/cli: bump version %s"

View file

@ -13,14 +13,7 @@
"node": ">=10.0.0"
},
"scripts": {
"tsc": "tsc",
"build": "run-s clean compile copy",
"clean": "rimraf ./build",
"compile": "babel src/ -d build/ --config-file ../../babel.config.js",
"copy": "copyfiles -u 1 -V \"src/templates/**/*\" ./build/",
"test": "run-s test:*",
"test:eslint": "eslint src test",
"test:unit": "jest"
"copy": "copyfiles -u 1 -V \"src/templates/**/*\" ./build/"
},
"repository": {
"type": "git",

View file

@ -1,4 +1,5 @@
import util from 'util'
import inquirer from 'inquirer'
import yarnInstall from 'yarn-install'
import {
@ -34,7 +35,7 @@ export const builder = (yargs) => {
.help()
}
export const runConfig = async function (useYarn, yes, exit) {
const runConfig = async function (useYarn, yes, exit) {
console.log(CONFIG_HELPER_INTRO)
const answers = await getAnswers(yes)
@ -150,3 +151,33 @@ export async function handler(argv) {
throw new Error(`something went wrong during setup: ${error.stack.slice(7)}`)
}
}
/**
* Helper utility used in `run` and `install` command to create config if none exist
* @param {string} command to be executed by user
* @param {string} message to show when no config is suppose to be created
* @param {boolean} useYarn parameter set to true if yarn is used
* @param {Function} runConfigCmd runConfig method to be replaceable for unit testing
*/
export async function missingConfigurationPrompt(command, message, useYarn = false, runConfigCmd = runConfig) {
const { config } = await inquirer.prompt([
{
type: 'confirm',
name: 'config',
message: `Error: Could not execute "${command}" due to missing configuration. Would you like to create one?`,
default: false
}
])
/**
* don't exit if running unit tests
*/
if (!config && !process.env.JEST_WORKER_ID) {
/* istanbul ignore next */
console.log(message)
/* istanbul ignore next */
return process.exit(0)
}
return await runConfigCmd(useYarn, false, true)
}

View file

@ -7,9 +7,9 @@ import {
replaceConfig,
findInConfig,
addServiceDeps,
convertPackageHashToObject,
missingConfigurationPrompt
convertPackageHashToObject
} from '../utils'
import { missingConfigurationPrompt } from './config'
import { SUPPORTED_PACKAGES, CLI_EPILOGUE } from '../constants'

View file

@ -1,9 +1,10 @@
import fs from 'fs-extra'
import path from 'path'
import Launcher from './../launcher'
import Watcher from './../watcher'
import { missingConfigurationPrompt } from '../utils'
import { missingConfigurationPrompt } from './config'
import Launcher from '../launcher'
import Watcher from '../watcher'
import { CLI_EPILOGUE } from '../constants'
export const command = 'run <configPath>'

View file

@ -8,7 +8,6 @@ import { SevereServiceError } from 'webdriverio'
import { execSync } from 'child_process'
import { promisify } from 'util'
import { runConfig } from './commands/config'
import { EXCLUSIVE_SERVICES, ANDROID_CONFIG, IOS_CONFIG, QUESTIONNAIRE } from './constants'
const log = logger('@wdio/cli:utils')
@ -205,29 +204,6 @@ export async function renderConfigurationFile (answers) {
fs.writeFileSync(path.join(process.cwd(), 'wdio.conf.js'), renderedTpl)
}
export async function missingConfigurationPrompt(command, message, useYarn = false) {
const { config } = await inquirer.prompt([
{
type: 'confirm',
name: 'config',
message: `Error: Could not execute "${command}" due to missing configuration. Would you like to create one?`,
default: false
}
])
/**
* don't exit if running unit tests
*/
if (!config && !process.env.JEST_WORKER_ID) {
/* istanbul ignore next */
console.log(message)
/* istanbul ignore next */
return process.exit(0)
}
return await runConfig(useYarn, false, true)
}
export const validateServiceAnswers = (answers) => {
let result = true

View file

@ -14,6 +14,7 @@ chalkMock.white = chalkMock
chalkMock.yellow = jest.fn().mockImplementation((...msg) => `yellow ${msg.join(' ')}`)
chalkMock.magenta = jest.fn().mockImplementation((msg) => `magenta ${msg}`)
chalkMock.bgGreen = jest.fn().mockImplementation((msg) => `bgGreen ${msg}`)
chalkMock.dim = jest.fn().mockImplementation((msg) => `dim ${msg}`)
chalkMock.supportsColor = { hasBasic: true }
chalkMock.bgYellow = chalkMock
chalkMock.bgRed = chalkMock

View file

@ -2,7 +2,7 @@ import yargs from 'yargs'
import yarnInstall from 'yarn-install'
import inquirer from 'inquirer'
import { handler, builder } from './../../src/commands/config'
import { handler, builder, missingConfigurationPrompt } from './../../src/commands/config'
import { addServiceDeps, convertPackageHashToObject, renderConfigurationFile, generateTestFiles, getPathForFileGeneration } from '../../src/utils'
jest.mock('../../src/utils', () => ({
@ -114,3 +114,37 @@ test('prints TypeScript setup message', async () => {
await handler({})
expect(consoleLogSpy.mock.calls).toMatchSnapshot()
})
describe('missingConfigurationPromp', () => {
it('should prompt user', async () => {
inquirer.prompt.mockImplementation(() => ({ config: true }))
await missingConfigurationPrompt(null, null, null, jest.fn())
expect(inquirer.prompt).toHaveBeenCalled()
})
it('should call function to initalize configuration helper', async () => {
const runConfig = jest.fn()
await missingConfigurationPrompt('test', null, false, runConfig)
expect(runConfig).toHaveBeenCalledWith(false, false, true)
})
it('should pass "yarn" flag to runConfig', async () => {
const runConfig = jest.fn()
await missingConfigurationPrompt('test', 'test message', true, runConfig)
expect(runConfig).toHaveBeenCalledWith(true, false, true)
})
it('should throw if error occurs', async () => {
const runConfig = jest.fn().mockImplementation(Promise.reject)
try {
await missingConfigurationPrompt('test', null, null, runConfig)
} catch (error) {
expect(error).toBeTruthy()
}
})
afterEach(() => {
inquirer.prompt.mockClear()
})
})

View file

@ -1,6 +1,7 @@
import yargs from 'yargs'
import fs from 'fs-extra'
import * as installCmd from './../../src/commands/install'
import * as configCmd from './../../src/commands/config'
import * as utils from './../../src/utils'
import yarnInstall from 'yarn-install'
@ -13,7 +14,7 @@ describe('Command: install', () => {
beforeEach(() => {
jest.spyOn(console, 'log')
jest.spyOn(process, 'exit').mockImplementation(() => {})
jest.spyOn(utils, 'missingConfigurationPrompt').mockImplementation(() => Promise.resolve())
jest.spyOn(configCmd, 'missingConfigurationPrompt').mockImplementation(() => Promise.resolve())
jest.spyOn(utils, 'addServiceDeps')
jest.spyOn(utils, 'replaceConfig')
@ -43,12 +44,12 @@ describe('Command: install', () => {
})
it('should prompt missing configuration', async () => {
jest.spyOn(utils, 'missingConfigurationPrompt').mockImplementation(() => Promise.reject())
jest.spyOn(configCmd, 'missingConfigurationPrompt').mockImplementation(() => Promise.reject())
fs.existsSync.mockReturnValue(false)
await installCmd.handler({ type: 'service', name: 'chromedriver', config: './wdio.conf.js' })
expect(utils.missingConfigurationPrompt).toHaveBeenCalledWith('install', `Cannot install packages without a WebdriverIO configuration.
expect(configCmd.missingConfigurationPrompt).toHaveBeenCalledWith('install', `Cannot install packages without a WebdriverIO configuration.
You can create one by running 'wdio config'`, undefined)
})
@ -114,6 +115,6 @@ You can create one by running 'wdio config'`, undefined)
utils.findInConfig.mockClear()
utils.addServiceDeps.mockClear()
utils.replaceConfig.mockClear()
utils.missingConfigurationPrompt.mockClear()
configCmd.missingConfigurationPrompt.mockClear()
})
})

View file

@ -1,7 +1,7 @@
import fs from 'fs-extra'
import yargs from 'yargs'
import * as runCmd from './../../src/commands/run'
import * as utils from './../../src/utils'
import * as configCmd from './../../src/commands/config'
jest.mock('./../../src/launcher', () => class LauncherMock {
run() {
@ -27,7 +27,7 @@ describe('Command: run', () => {
beforeEach(() => {
fs.existsSync.mockImplementation(() => true)
fs.existsSync.mockClear()
jest.spyOn(utils, 'missingConfigurationPrompt').mockImplementation(() => {})
jest.spyOn(configCmd, 'missingConfigurationPrompt').mockImplementation(() => {})
jest.spyOn(console, 'error')
jest.spyOn(process, 'openStdin').mockImplementation(
() => ({ setEncoding: setEncodingMock, on: onMock }))
@ -37,8 +37,8 @@ describe('Command: run', () => {
fs.existsSync.mockImplementation(() => false)
await runCmd.handler({ configPath: 'foo/bar' })
expect(utils.missingConfigurationPrompt).toHaveBeenCalled()
expect(utils.missingConfigurationPrompt)
expect(configCmd.missingConfigurationPrompt).toHaveBeenCalled()
expect(configCmd.missingConfigurationPrompt)
.toHaveBeenCalledWith('run', 'No WebdriverIO configuration found in "foo/bar"')
fs.existsSync.mockClear()
@ -90,6 +90,6 @@ describe('Command: run', () => {
process.openStdin.mockReset()
console.error.mockReset()
fs.existsSync.mockClear()
utils.missingConfigurationPrompt.mockClear()
configCmd.missingConfigurationPrompt.mockClear()
})
})

View file

@ -1,6 +1,5 @@
import fs from 'fs-extra'
import ejs from 'ejs'
import inquirer from 'inquirer'
import readDir from 'recursive-readdir'
import childProcess from 'child_process'
import { SevereServiceError } from 'webdriverio'
@ -14,7 +13,6 @@ import {
replaceConfig,
addServiceDeps,
convertPackageHashToObject,
missingConfigurationPrompt,
renderConfigurationFile,
validateServiceAnswers,
getCapabilities,
@ -24,8 +22,6 @@ import {
} from '../src/utils'
import { runConfig } from '../src/commands/config'
jest.mock('child_process', function () {
const m = {
execSyncRes: 'APPIUM_MISSING',
@ -338,39 +334,6 @@ describe('convertPackageHashToObject', () => {
})
})
describe('missingConfigurationPromp', () => {
it('should prompt user', async () => {
inquirer.prompt.mockImplementation(() => ({ config: true }))
await missingConfigurationPrompt()
expect(inquirer.prompt).toHaveBeenCalled()
})
it('should call function to initalize configuration helper', async () => {
await missingConfigurationPrompt('test')
expect(runConfig).toHaveBeenCalledWith(false, false, true)
})
it('should pass "yarn" flag to runConfig', async () => {
await missingConfigurationPrompt('test', 'test message', true)
expect(runConfig).toHaveBeenCalledWith(true, false, true)
})
it('should throw if error occurs', async () => {
runConfig.mockImplementation(Promise.reject)
try {
await missingConfigurationPrompt('test')
} catch (error) {
expect(error).toBeTruthy()
}
})
afterEach(() => {
runConfig.mockClear()
inquirer.prompt.mockClear()
})
})
test('validateServiceAnswers', () => {
expect(validateServiceAnswers(['wdio-chromedriver-service', '@wdio/selenium-standalone-service']))
.toContain('wdio-chromedriver-service cannot work together with @wdio/selenium-standalone-service')

View file

@ -0,0 +1,11 @@
{
"extends": "../../tsconfig.prod",
"compilerOptions": {
"baseUrl": ".",
"outDir": "./build",
"rootDir": "./src"
},
"include": [
"src/**/*"
]
}

View file

@ -1,2 +1,4 @@
src
tests
tests
tsconfig.json
tsconfig.prod.json

View file

@ -1 +0,0 @@
message = "@wdio/concise-reporter: bump version %s"

View file

@ -9,15 +9,6 @@
"engines": {
"node": ">=10.0.0"
},
"scripts": {
"tsc": "tsc",
"build": "run-s clean compile",
"clean": "rimraf ./build",
"compile": "babel src/ -d build/ --config-file ../../babel.config.js",
"test": "run-s test:*",
"test:eslint": "eslint src test",
"test:unit": "jest"
},
"repository": {
"type": "git",
"url": "git://github.com/webdriverio/webdriverio.git"

View file

@ -0,0 +1,11 @@
{
"extends": "../../tsconfig.prod",
"compilerOptions": {
"baseUrl": ".",
"outDir": "./build",
"rootDir": "./src"
},
"include": [
"src/**/*"
]
}

View file

@ -1,2 +1,4 @@
src
tests
tsconfig.json
tsconfig.prod.json

View file

@ -1 +0,0 @@
message = "@wdio/config: bump version %s"

View file

@ -9,15 +9,6 @@
"engines": {
"node": ">=10.0.0"
},
"scripts": {
"tsc": "tsc",
"build": "run-s clean compile",
"clean": "rimraf ./build",
"compile": "babel src/ -d build/ --config-file ../../babel.config.js",
"test": "run-s test:*",
"test:eslint": "eslint src test",
"test:unit": "jest"
},
"repository": {
"type": "git",
"url": "git://github.com/webdriverio/webdriverio.git"

View file

@ -0,0 +1,11 @@
{
"extends": "../../tsconfig.prod",
"compilerOptions": {
"baseUrl": ".",
"outDir": "./build",
"rootDir": "./src"
},
"include": [
"src/**/*"
]
}

View file

@ -0,0 +1,4 @@
src
tests
tsconfig.json
tsconfig.prod.json

View file

@ -9,15 +9,6 @@
"engines": {
"node": ">=10.0.0"
},
"scripts": {
"tsc": "tsc",
"build": "run-s clean compile",
"clean": "rimraf ./build",
"compile": "babel src/ -d build/ --config-file ../../babel.config.js",
"test": "run-s test:*",
"test:eslint": "eslint src test",
"test:unit": "jest"
},
"repository": {
"type": "git",
"url": "git://github.com/webdriverio/webdriverio.git"

View file

@ -0,0 +1,11 @@
{
"extends": "../../tsconfig.prod",
"compilerOptions": {
"baseUrl": ".",
"outDir": "./build",
"rootDir": "./src"
},
"include": [
"src/**/*"
]
}

View file

@ -1,2 +1,4 @@
src
tests
tests
tsconfig.json
tsconfig.prod.json

View file

@ -1 +0,0 @@
message = "@wdio/cucumber-framework: bump version %s"

View file

@ -9,15 +9,6 @@
"engines": {
"node": ">=10.0.0"
},
"scripts": {
"tsc": "tsc",
"build": "run-s clean compile",
"clean": "rimraf ./build",
"compile": "babel src/ -d build/ --config-file ../../babel.config.js",
"test": "run-s test:*",
"test:eslint": "eslint src test",
"test:unit": "jest"
},
"repository": {
"type": "git",
"url": "git://github.com/webdriverio/webdriverio.git"

View file

@ -0,0 +1,11 @@
{
"extends": "../../tsconfig.prod",
"compilerOptions": {
"baseUrl": ".",
"outDir": "./build",
"rootDir": "./src"
},
"include": [
"src/**/*"
]
}

View file

@ -1,2 +1,4 @@
src
tests
tsconfig.json
tsconfig.prod.json

View file

@ -1 +0,0 @@
message = "@wdio/devtools-service: bump version %s"

View file

@ -9,15 +9,6 @@
"engines": {
"node": ">=10.0.0"
},
"scripts": {
"tsc": "tsc",
"build": "run-s clean compile",
"clean": "rimraf ./build",
"compile": "babel src/ -d build/ --config-file ../../babel.config.js",
"test": "run-s test:*",
"test:eslint": "eslint src test",
"test:unit": "jest"
},
"repository": {
"type": "git",
"url": "git://github.com/webdriverio/webdriverio.git"

View file

@ -0,0 +1,11 @@
{
"extends": "../../tsconfig.prod",
"compilerOptions": {
"baseUrl": ".",
"outDir": "./build",
"rootDir": "./src"
},
"include": [
"src/**/*"
]
}

View file

@ -1,2 +1,4 @@
src
tests
tsconfig.json
tsconfig.prod.json

View file

@ -1 +0,0 @@
message = "@wdio/dot-reporter: bump version %s"

View file

@ -9,15 +9,6 @@
"engines": {
"node": ">=10.0.0"
},
"scripts": {
"tsc": "tsc",
"build": "run-s clean compile",
"clean": "rimraf ./build",
"compile": "babel src/ -d build/ --config-file ../../babel.config.js",
"test": "run-s test:*",
"test:eslint": "eslint src test",
"test:unit": "jest"
},
"repository": {
"type": "git",
"url": "git://github.com/webdriverio/webdriverio.git"

View file

@ -0,0 +1,11 @@
{
"extends": "../../tsconfig.prod",
"compilerOptions": {
"baseUrl": ".",
"outDir": "./build",
"rootDir": "./src"
},
"include": [
"src/**/*"
]
}

View file

@ -1,2 +1,4 @@
src
tests
tsconfig.json
tsconfig.prod.json

View file

@ -1 +0,0 @@
message = "@wdio/firefox-adapter-service: bump version %s"

View file

@ -9,15 +9,6 @@
"engines": {
"node": ">=10.0.0"
},
"scripts": {
"tsc": "tsc",
"build": "run-s clean compile",
"clean": "rimraf ./build",
"compile": "babel src/ -d build/ --config-file ../../babel.config.js",
"test": "run-s test:*",
"test:eslint": "eslint src test",
"test:unit": "jest"
},
"repository": {
"type": "git",
"url": "git://github.com/webdriverio/webdriverio.git"

View file

@ -0,0 +1,11 @@
{
"extends": "../../tsconfig.prod",
"compilerOptions": {
"baseUrl": ".",
"outDir": "./build",
"rootDir": "./src"
},
"include": [
"src/**/*"
]
}

View file

@ -1,2 +1,4 @@
src
tests
tests
tsconfig.json
tsconfig.prod.json

View file

@ -1 +0,0 @@
message = "@wdio/jasmine-framework: bump version %s"

View file

@ -9,15 +9,6 @@
"engines": {
"node": ">=10.0.0"
},
"scripts": {
"tsc": "tsc",
"build": "run-s clean compile",
"clean": "rimraf ./build",
"compile": "babel src/ -d build/ --config-file ../../babel.config.js",
"test": "run-s test:*",
"test:eslint": "eslint src test",
"test:unit": "jest"
},
"repository": {
"type": "git",
"url": "git://github.com/webdriverio/webdriverio.git"

View file

@ -0,0 +1,11 @@
{
"extends": "../../tsconfig.prod",
"compilerOptions": {
"baseUrl": ".",
"outDir": "./build",
"rootDir": "./src"
},
"include": [
"src/**/*"
]
}

View file

@ -1,2 +1,4 @@
src
tests
tsconfig.json
tsconfig.prod.json

View file

@ -1 +0,0 @@
message = "@wdio/junit-reporter: bump version %s"

View file

@ -9,15 +9,6 @@
"engines": {
"node": ">=10.0.0"
},
"scripts": {
"tsc": "tsc",
"build": "run-s clean compile",
"clean": "rimraf ./build",
"compile": "babel src/ -d build/ --config-file ../../babel.config.js",
"test": "run-s test:*",
"test:eslint": "eslint src test",
"test:unit": "jest"
},
"repository": {
"type": "git",
"url": "git://github.com/webdriverio/webdriverio.git"

View file

@ -0,0 +1,11 @@
{
"extends": "../../tsconfig.prod",
"compilerOptions": {
"baseUrl": ".",
"outDir": "./build",
"rootDir": "./src"
},
"include": [
"src/**/*"
]
}

View file

@ -1,2 +1,4 @@
src
tests
tsconfig.json
tsconfig.prod.json

View file

@ -1 +0,0 @@
message = "@wdio/lambda-runner: bump version %s"

View file

@ -9,15 +9,6 @@
"engines": {
"node": ">=10.0.0"
},
"scripts": {
"tsc": "tsc",
"build": "run-s clean compile",
"clean": "rimraf ./build",
"compile": "babel src/ -d build/ --config-file ../../babel.config.js",
"test": "run-s test:*",
"test:eslint": "eslint src test",
"test:unit": "jest"
},
"repository": {
"type": "git",
"url": "git://github.com/webdriverio/webdriverio.git"

View file

@ -0,0 +1,11 @@
{
"extends": "../../tsconfig.prod",
"compilerOptions": {
"baseUrl": ".",
"outDir": "./build",
"rootDir": "./src"
},
"include": [
"src/**/*"
]
}

View file

@ -1,2 +1,4 @@
src
tests
tsconfig.json
tsconfig.prod.json

View file

@ -1 +0,0 @@
message = "@wdio/local-runner: bump version %s"

View file

@ -9,15 +9,6 @@
"engines": {
"node": ">=10.0.0"
},
"scripts": {
"tsc": "tsc",
"build": "run-s clean compile",
"clean": "rimraf ./build",
"compile": "babel src/ -d build/ --config-file ../../babel.config.js",
"test": "run-s test:*",
"test:eslint": "eslint src test",
"test:unit": "jest"
},
"repository": {
"type": "git",
"url": "git://github.com/webdriverio/webdriverio.git"

View file

@ -4,6 +4,7 @@ export default class WDIORunnerRepl extends WDIORepl {
constructor (childProcess, options) {
super(options)
this.childProcess = childProcess
this.commandIsRunning = false
}
_getError(params) {

View file

@ -9,7 +9,7 @@ const sleep = (ms = 100) => new Promise(
(resolve) => setTimeout(resolve, ms))
let exitHookFn, runner
const origExit = ::process.exit
const origExit = process.exit.bind(process)
beforeAll(() => {
jest.spyOn(process, 'on')

View file

@ -0,0 +1,11 @@
{
"extends": "../../tsconfig.prod",
"compilerOptions": {
"baseUrl": ".",
"outDir": "./build",
"rootDir": "./src"
},
"include": [
"src/**/*"
]
}

View file

@ -1,2 +1,4 @@
src
tests
tsconfig.json
tsconfig.prod.json

View file

@ -1 +0,0 @@
message = "@wdio/logger: bump version %s"

View file

@ -9,15 +9,6 @@
"engines": {
"node": ">=10.0.0"
},
"scripts": {
"tsc": "tsc",
"build": "run-s clean compile",
"clean": "rimraf ./build",
"compile": "babel src/ -d build/ --config-file ../../babel.config.js",
"test": "run-s test:*",
"test:eslint": "eslint src test",
"test:unit": "jest"
},
"repository": {
"type": "git",
"url": "git://github.com/webdriverio/webdriverio.git"

View file

@ -0,0 +1,11 @@
{
"extends": "../../tsconfig.prod",
"compilerOptions": {
"baseUrl": ".",
"outDir": "./build",
"rootDir": "./src"
},
"include": [
"src/**/*"
]
}

View file

@ -1,2 +1,4 @@
src
tests
tsconfig.json
tsconfig.prod.json

View file

@ -1 +0,0 @@
message = "@wdio/mocha-framework: bump version %s"

View file

@ -9,15 +9,6 @@
"engines": {
"node": ">=10.0.0"
},
"scripts": {
"tsc": "tsc",
"build": "run-s clean compile",
"clean": "rimraf ./build",
"compile": "babel src/ -d build/ --config-file ../../babel.config.js",
"test": "run-s test:*",
"test:eslint": "eslint src test",
"test:unit": "jest"
},
"repository": {
"type": "git",
"url": "git://github.com/webdriverio/webdriverio.git"

View file

@ -0,0 +1,11 @@
{
"extends": "../../tsconfig.prod",
"compilerOptions": {
"baseUrl": ".",
"outDir": "./build",
"rootDir": "./src"
},
"include": [
"src/**/*"
]
}

View file

@ -1,2 +1,2 @@
src
tests
tests

Some files were not shown because too many files have changed in this diff Show more