Skip to content

Commit

Permalink
(internal): fix usage of intialise wording in variables, comments a…
Browse files Browse the repository at this point in the history
…nd elsewhere (#11672)

* (internal): fix usage of wrong wording in variables, comments and elsewhere

* fix file naming
  • Loading branch information
christian-bromann committed Nov 15, 2023
1 parent e8ec977 commit 0ccef16
Show file tree
Hide file tree
Showing 49 changed files with 143 additions and 143 deletions.
2 changes: 1 addition & 1 deletion __mocks__/@wdio/local-runner.ts
Expand Up @@ -5,7 +5,7 @@ export default class LocalRunnerMock {
configFile: string
config: WebdriverIO.Config
workerPool: Record<string, WorkerInstance> = {}
initialise = vi.fn()
initialize = vi.fn()

constructor (configFile: string, config: WebdriverIO.Config) {
this.configFile = configFile
Expand Down
8 changes: 4 additions & 4 deletions __mocks__/@wdio/utils.ts
Expand Up @@ -26,7 +26,7 @@ class DotReporter {

class RunnerMock {
shutdown = vi.fn().mockResolvedValue(true)
initialise = vi.fn()
initialize = vi.fn()
}
class FoobarServiceMock {
beforeSuite () {}
Expand Down Expand Up @@ -68,13 +68,13 @@ const pluginMocks = {
framework: frameworkMocks
}

export const initialisePlugin = vi.fn().mockImplementation(
export const initializePlugin = vi.fn().mockImplementation(
async (name: keyof typeof frameworkMocks, type: keyof typeof pluginMocks) => (
{ default: (pluginMocks[type] as any)[name] }
)
)
export const initialiseWorkerService = vi.fn().mockReturnValue([])
export const initialiseLauncherService = vi.fn().mockReturnValue({
export const initializeWorkerService = vi.fn().mockReturnValue([])
export const initializeLauncherService = vi.fn().mockReturnValue({
launcherServices: [],
ignoredWorkerServices: []
})
Expand Down
4 changes: 2 additions & 2 deletions examples/wdio.conf.js
Expand Up @@ -227,12 +227,12 @@ exports.config = {
onPrepare: function (config, capabilities) {
},
/**
* Gets executed before a worker process is spawned and can be used to initialise specific service
* Gets executed before a worker process is spawned and can be used to initialize 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 {string[]} specs specs to be run in the worker process
* @param {object} args object that will be merged with the main configuration once worker is initialised
* @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) {
Expand Down
2 changes: 1 addition & 1 deletion examples/wdio/vite-vue-example/wdio.conf.ts
Expand Up @@ -182,7 +182,7 @@ export const config: Options.Testrunner = {
// onPrepare: function (config, capabilities) {
// },
/**
* Gets executed before a worker process is spawned and can be used to initialise specific service
* Gets executed before a worker process is spawned and can be used to initialize 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
Expand Down
6 changes: 3 additions & 3 deletions packages/wdio-browser-runner/src/index.ts
Expand Up @@ -66,9 +66,9 @@ export default class BrowserRunner extends LocalRunner {
}

/**
* nothing to initialise when running locally
* nothing to initialize when running locally
*/
async initialise() {
async initialize() {
log.info('Initiate browser environment')
if (typeof this.#coverageOptions.clean === 'undefined' || this.#coverageOptions.clean) {
const reportsDirectoryExist = await fs.access(this.#reportsDirectory)
Expand All @@ -87,7 +87,7 @@ export default class BrowserRunner extends LocalRunner {
log.error(`Failed to optimize Vite config: ${(err as Error).stack}`)
}

await super.initialise()
await super.initialize()
}

async run (runArgs: RunArgs): Promise<WorkerInstance> {
Expand Down
8 changes: 4 additions & 4 deletions packages/wdio-browser-runner/tests/runner.test.ts
Expand Up @@ -65,12 +65,12 @@ describe('BrowserRunner', () => {
} as any)).not.toThrow()
})

it('initialise', async () => {
it('initialize', async () => {
const runner = new BrowserRunner({}, {
rootDir: '/foo/bar',
framework: 'mocha'
} as any)
await runner.initialise()
await runner.initialize()
expect(fs.rm).toBeCalledWith(
path.join('/foo/bar', 'coverage'),
{ recursive: true }
Expand All @@ -82,7 +82,7 @@ describe('BrowserRunner', () => {
rootDir: '/foo/bar',
framework: 'mocha'
} as any)
await runner.initialise()
await runner.initialize()

const on = vi.fn()
vi.mocked(LocalRunner.prototype.run).mockReturnValue({ on } as any)
Expand Down Expand Up @@ -114,7 +114,7 @@ describe('BrowserRunner', () => {
framework: 'mocha'
} as any)
runner['_generateCoverageReports'] = vi.fn()
await runner.initialise()
await runner.initialize()
await runner.shutdown()
expect(LocalRunner.prototype.shutdown).toBeCalledTimes(1)
expect(runner['_generateCoverageReports']).toBeCalledTimes(1)
Expand Down
12 changes: 6 additions & 6 deletions packages/wdio-cli/src/launcher.ts
Expand Up @@ -5,7 +5,7 @@ import exitHook from 'async-exit-hook'
import logger from '@wdio/logger'
import { validateConfig } from '@wdio/config'
import { ConfigParser } from '@wdio/config/node'
import { initialisePlugin, initialiseLauncherService, sleep } from '@wdio/utils'
import { initializePlugin, initializeLauncherService, sleep } from '@wdio/utils'
import { setupDriver, setupBrowser } from '@wdio/utils/node'
import type { Options, Capabilities, Services } from '@wdio/types'

Expand Down Expand Up @@ -110,7 +110,7 @@ class Launcher {
config.runnerEnv!.FORCE_COLOR = Number(this.interface.hasAnsiSupport)

const [runnerName, runnerOptions] = Array.isArray(config.runner) ? config.runner : [config.runner, {} as WebdriverIO.BrowserRunnerOptions]
const Runner = (await initialisePlugin(runnerName, 'runner') as Services.RunnerPlugin).default
const Runner = (await initializePlugin(runnerName, 'runner') as Services.RunnerPlugin).default
this.runner = new Runner(runnerOptions, config)

/**
Expand All @@ -122,15 +122,15 @@ class Launcher {

try {
const caps = this.configParser.getCapabilities() as Capabilities.RemoteCapabilities
const { ignoredWorkerServices, launcherServices } = await initialiseLauncherService(config, caps as Capabilities.DesiredCapabilities)
const { ignoredWorkerServices, launcherServices } = await initializeLauncherService(config, caps as Capabilities.DesiredCapabilities)
this._launcher = launcherServices
this._args.ignoredWorkerServices = ignoredWorkerServices

/**
* run pre test tasks for runner plugins
* (e.g. deploy Lambda function to AWS)
*/
await this.runner.initialise()
await this.runner.initialize()

/**
* run onPrepare hook
Expand Down Expand Up @@ -387,7 +387,7 @@ class Launcher {
retries: number
) {
if (!this.runner || !this.interface) {
throw new Error('Internal Error: no runner initialised, call run() first')
throw new Error('Internal Error: no runner initialized, call run() first')
}

const config = this.configParser.getConfig()
Expand Down Expand Up @@ -475,7 +475,7 @@ class Launcher {

private _workerHookError (error: HookError) {
if (!this.interface) {
throw new Error('Internal Error: no interface initialised, call run() first')
throw new Error('Internal Error: no interface initialized, call run() first')
}

this.interface.logHookError(error)
Expand Down
2 changes: 1 addition & 1 deletion packages/wdio-cli/src/templates/wdio.conf.tpl.ejs
Expand Up @@ -228,7 +228,7 @@ if (answers.isUsingTypeScript) {
// onPrepare: function (config, capabilities) {
// },
/**
* Gets executed before a worker process is spawned and can be used to initialise specific service
* Gets executed before a worker process is spawned and can be used to initialize 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
Expand Down
2 changes: 1 addition & 1 deletion packages/wdio-cli/src/watcher.ts
Expand Up @@ -120,7 +120,7 @@ export default class Watcher {
*/
getWorkers (predicate?: ValueKeyIteratee<Workers.Worker> | null | undefined, includeBusyWorker?: boolean): Workers.WorkerPool {
if (!this._launcher.runner) {
throw new Error('Internal Error: no runner initialised, call run() first')
throw new Error('Internal Error: no runner initialized, call run() first')
}

let workers = this._launcher.runner.workerPool
Expand Down
4 changes: 2 additions & 2 deletions packages/wdio-cli/tests/launcher.test.ts
Expand Up @@ -699,7 +699,7 @@ describe('launcher', () => {
getConfig: vi.fn().mockReturnValue(config),
initialize: vi.fn()
} as any
launcher.runner = { initialise: vi.fn(), shutdown: vi.fn() } as any
launcher.runner = { initialize: vi.fn(), shutdown: vi.fn() } as any
launcher['_runMode'] = vi.fn().mockImplementation(() => 0)
})

Expand All @@ -712,7 +712,7 @@ describe('launcher', () => {

expect(launcher.configParser.getCapabilities).toBeCalledTimes(2)
expect(launcher.configParser.getConfig).toBeCalledTimes(1)
expect(launcher.runner!.initialise).toBeCalledTimes(1)
expect(launcher.runner!.initialize).toBeCalledTimes(1)
// @ts-ignore
expect(config.onPrepare![0]).toBeCalledTimes(1)
expect(launcher['_runMode']).toBeCalledTimes(1)
Expand Down
2 changes: 1 addition & 1 deletion packages/wdio-cli/tests/watcher.test.ts
Expand Up @@ -75,7 +75,7 @@ class WorkerMock extends EventEmitter implements Workers.Worker {
}

describe('watcher', () => {
it('should initialise properly', async () => {
it('should initialize properly', async () => {
const wdioConf = path.join(__dirname, '__fixtures__', 'wdio.conf')
const watcher = new Watcher(wdioConf, {})
expect(watcher['_launcher']).toBeDefined()
Expand Down
6 changes: 3 additions & 3 deletions packages/wdio-config/src/node/ConfigParser.ts
Expand Up @@ -71,7 +71,7 @@ export default class ConfigParser {
*/
async initialize (object: MergeConfig = {}) {
/**
* only run auto compile functionality once but allow the config parse to be initialised
* only run auto compile functionality once but allow the config parse to be initialized
* multiple times, e.g. when used with the packages/wdio-cli/src/watcher.ts
*/
if (!this.#isInitialised) {
Expand Down Expand Up @@ -370,7 +370,7 @@ export default class ConfigParser {
*/
getConfig () {
if (!this.#isInitialised) {
throw new Error('ConfigParser was not initialised, call "await config.initialize()" first!')
throw new Error('ConfigParser was not initialized, call "await config.initialize()" first!')
}
return this._config as Required<Options.Testrunner>
}
Expand All @@ -380,7 +380,7 @@ export default class ConfigParser {
*/
getCapabilities(i?: number) {
if (!this.#isInitialised) {
throw new Error('ConfigParser was not initialised, call "await config.initialize()" first!')
throw new Error('ConfigParser was not initialized, call "await config.initialize()" first!')
}

if (typeof i === 'number' && Array.isArray(this._capabilities) && this._capabilities[i]) {
Expand Down
4 changes: 2 additions & 2 deletions packages/wdio-jasmine-framework/src/index.ts
Expand Up @@ -172,7 +172,7 @@ class JasmineAdapter {
})

/**
* for a clean stdout we need to avoid that Jasmine initialises the
* for a clean stdout we need to avoid that Jasmine initializes the
* default reporter
*/
Jasmine.prototype.configureDefaultReporter = NOOP
Expand Down Expand Up @@ -234,7 +234,7 @@ class JasmineAdapter {
this._hasTests = this._totalTests > 0
} catch (err: any) {
log.warn(
'Unable to load spec files quite likely because they rely on `browser` object that is not fully initialised.\n' +
'Unable to load spec files quite likely because they rely on `browser` object that is not fully initialized.\n' +
'`browser` object has only `capabilities` and some flags like `isMobile`.\n' +
'Helper files that use other `browser` commands have to be moved to `before` hook.\n' +
`Spec file(s): ${this._specs.join(',')}\n`,
Expand Down
4 changes: 2 additions & 2 deletions packages/wdio-local-runner/src/index.ts
Expand Up @@ -26,9 +26,9 @@ export default class LocalRunner {
) {}

/**
* nothing to initialise when running locally
* nothing to initialize when running locally
*/
initialise () {}
initialize () {}

getWorkerCount () {
return Object.keys(this.workerPool).length
Expand Down
2 changes: 1 addition & 1 deletion packages/wdio-local-runner/tests/localRunner.test.ts
Expand Up @@ -218,5 +218,5 @@ test('should shut down worker processes in watch mode - mutliremote', async () =

test('should avoid shutting down if worker is not busy', async () => {
const runner = new LocalRunner(undefined as never, {} as any)
expect(runner.initialise()).toBe(undefined)
expect(runner.initialize()).toBe(undefined)
})
2 changes: 1 addition & 1 deletion packages/wdio-mocha-framework/src/index.ts
Expand Up @@ -106,7 +106,7 @@ class MochaAdapter {
this._hasTests = mochaRunner.total > 0
} catch (err: any) {
const error = '' +
'Unable to load spec files quite likely because they rely on `browser` object that is not fully initialised.\n' +
'Unable to load spec files quite likely because they rely on `browser` object that is not fully initialized.\n' +
'`browser` object has only `capabilities` and some flags like `isMobile`.\n' +
'Helper files that use other `browser` commands have to be moved to `before` hook.\n' +
`Spec file(s): ${this._specs.join(',')}\n` +
Expand Down
2 changes: 1 addition & 1 deletion packages/wdio-repl/src/index.ts
Expand Up @@ -129,7 +129,7 @@ export default class WDIORepl {

start (context?: vm.Context) {
if (this._replServer) {
throw new Error('a repl was already initialised')
throw new Error('a repl was already initialized')
}

if (context) {
Expand Down
@@ -1,6 +1,6 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`should get initialised 1`] = `
exports[`should get initialized 1`] = `
{
"_duration": 0,
"cid": "0-0",
Expand Down
2 changes: 1 addition & 1 deletion packages/wdio-reporter/tests/stats/hook.test.ts
@@ -1,7 +1,7 @@
import { test, expect } from 'vitest'
import HookStats from '../../src/stats/hook.js'

test('should get initialised', () => {
test('should get initialized', () => {
const hook = new HookStats({
cid: '0-0',
title: 'foobar',
Expand Down
2 changes: 1 addition & 1 deletion packages/wdio-reporter/tests/stats/runner.test.ts
@@ -1,7 +1,7 @@
import { test, expect } from 'vitest'
import RunnerStats from '../../src/stats/runner.js'

test('should get initialised', () => {
test('should get initialized', () => {
const capabilities = { browserName: 'chrome' }
const config = { outputDir: 'foo', logFile: 'bar', capabilities: {} }
const specs = ['./foo/bar.js']
Expand Down
2 changes: 1 addition & 1 deletion packages/wdio-reporter/tests/stats/suite.test.ts
@@ -1,7 +1,7 @@
import { test, expect } from 'vitest'
import SuiteStats from '../../src/stats/suite.js'

test('should get initialised', () => {
test('should get initialized', () => {
const suite = new SuiteStats({
cid: '0-0',
title: 'foobar',
Expand Down
2 changes: 1 addition & 1 deletion packages/wdio-reporter/tests/stats/test.test.ts
Expand Up @@ -29,7 +29,7 @@ describe('TestStats', () => {
expect(stat.start instanceof Date).toBe(true)
})

it('should be initialised with correct values', () => {
it('should be initialized with correct values', () => {
stat.complete = vi.fn()

expect(stat.type).toBe('test')
Expand Down
14 changes: 7 additions & 7 deletions packages/wdio-runner/src/index.ts
Expand Up @@ -3,7 +3,7 @@ import path from 'node:path'
import { EventEmitter } from 'node:events'

import logger from '@wdio/logger'
import { initialiseWorkerService, initialisePlugin, executeHooksWithArgs } from '@wdio/utils'
import { initializeWorkerService, initializePlugin, executeHooksWithArgs } from '@wdio/utils'
import { ConfigParser } from '@wdio/config/node'
import { _setGlobal } from '@wdio/globals'
import { expect, setOptions } from 'expect-webdriverio'
Expand All @@ -13,7 +13,7 @@ import type { Options, Capabilities } from '@wdio/types'

import BrowserFramework from './browser.js'
import BaseReporter from './reporter.js'
import { initialiseInstance, filterLogTypes, getInstancesData } from './utils.js'
import { initializeInstance, filterLogTypes, getInstancesData } from './utils.js'
import type {
BeforeArgs, AfterArgs, BeforeSessionArgs, AfterSessionArgs, RunParams,
TestFramework, SingleConfigOption, MultiRemoteCaps, SessionStartedMessage,
Expand Down Expand Up @@ -82,7 +82,7 @@ export default class Runner extends EventEmitter {
/**
* run `beforeSession` command before framework and browser are initiated
*/
;(await initialiseWorkerService(
;(await initializeWorkerService(
this._config as Options.Testrunner,
caps as WebdriverIO.Capabilities,
args.ignoredWorkerServices
Expand All @@ -95,7 +95,7 @@ export default class Runner extends EventEmitter {
await this._reporter.initReporters()

/**
* initialise framework
* initialize framework
*/
this._framework = await this.#initFramework(cid, this._config, caps, this._reporter, specs)
process.send!({ name: 'testFrameworkInit', content: { cid, caps, specs, hasTests: this._framework.hasTests() } })
Expand Down Expand Up @@ -207,10 +207,10 @@ export default class Runner extends EventEmitter {
const runner = Array.isArray(config.runner) ? config.runner[0] : config.runner

/**
* initialise framework adapter when running remote browser tests
* initialize framework adapter when running remote browser tests
*/
if (runner === 'local') {
const framework = (await initialisePlugin(config.framework as string, 'framework')).default as unknown as TestFramework
const framework = (await initializePlugin(config.framework as string, 'framework')).default as unknown as TestFramework
return framework.init(cid, config, specs, capabilities, reporter)
}

Expand Down Expand Up @@ -284,7 +284,7 @@ export default class Runner extends EventEmitter {
const customStubCommands: [string, (...args: any[]) => any, boolean][] = (this._browser as any | undefined)?.customCommands || []
const overwrittenCommands: [any, (...args: any[]) => any, boolean][] = (this._browser as any | undefined)?.overwrittenCommands || []

this._browser = await initialiseInstance(config, caps, this._isMultiremote)
this._browser = await initializeInstance(config, caps, this._isMultiremote)
_setGlobal('browser', this._browser, config.injectGlobals)
_setGlobal('driver', this._browser, config.injectGlobals)

Expand Down

0 comments on commit 0ccef16

Please sign in to comment.