codeceptjs 4.0.0-beta.5 → 4.0.0-beta.6.esm-aria
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -45
- package/bin/codecept.js +46 -57
- package/lib/actor.js +15 -11
- package/lib/ai.js +6 -5
- package/lib/assert/empty.js +9 -8
- package/lib/assert/equal.js +15 -17
- package/lib/assert/error.js +2 -2
- package/lib/assert/include.js +9 -11
- package/lib/assert/throws.js +1 -1
- package/lib/assert/truth.js +8 -5
- package/lib/assert.js +18 -18
- package/lib/codecept.js +66 -107
- package/lib/colorUtils.js +48 -50
- package/lib/command/check.js +32 -27
- package/lib/command/configMigrate.js +11 -10
- package/lib/command/definitions.js +16 -10
- package/lib/command/dryRun.js +16 -16
- package/lib/command/generate.js +29 -26
- package/lib/command/gherkin/init.js +36 -38
- package/lib/command/gherkin/snippets.js +14 -14
- package/lib/command/gherkin/steps.js +21 -18
- package/lib/command/info.js +8 -8
- package/lib/command/init.js +34 -31
- package/lib/command/interactive.js +11 -10
- package/lib/command/list.js +10 -9
- package/lib/command/run-multiple/chunk.js +5 -5
- package/lib/command/run-multiple/collection.js +5 -5
- package/lib/command/run-multiple/run.js +3 -3
- package/lib/command/run-multiple.js +16 -13
- package/lib/command/run-rerun.js +6 -7
- package/lib/command/run-workers.js +10 -24
- package/lib/command/run.js +8 -8
- package/lib/command/utils.js +20 -18
- package/lib/command/workers/runTests.js +117 -269
- package/lib/config.js +111 -49
- package/lib/container.js +299 -102
- package/lib/data/context.js +6 -5
- package/lib/data/dataScenarioConfig.js +1 -1
- package/lib/data/dataTableArgument.js +1 -1
- package/lib/data/table.js +1 -1
- package/lib/effects.js +94 -10
- package/lib/els.js +11 -9
- package/lib/event.js +11 -10
- package/lib/globals.js +141 -0
- package/lib/heal.js +12 -12
- package/lib/helper/AI.js +1 -1
- package/lib/helper/ApiDataFactory.js +16 -13
- package/lib/helper/FileSystem.js +32 -12
- package/lib/helper/GraphQL.js +1 -1
- package/lib/helper/GraphQLDataFactory.js +1 -1
- package/lib/helper/JSONResponse.js +19 -30
- package/lib/helper/Mochawesome.js +9 -28
- package/lib/helper/Playwright.js +668 -265
- package/lib/helper/Puppeteer.js +284 -169
- package/lib/helper/REST.js +29 -12
- package/lib/helper/WebDriver.js +191 -71
- package/lib/helper/errors/ConnectionRefused.js +6 -6
- package/lib/helper/errors/ElementAssertion.js +11 -16
- package/lib/helper/errors/ElementNotFound.js +5 -9
- package/lib/helper/errors/RemoteBrowserConnectionRefused.js +5 -5
- package/lib/helper/extras/Console.js +11 -11
- package/lib/helper/extras/PlaywrightLocator.js +110 -0
- package/lib/helper/extras/PlaywrightPropEngine.js +18 -18
- package/lib/helper/extras/PlaywrightRestartOpts.js +23 -23
- package/lib/helper/extras/Popup.js +1 -1
- package/lib/helper/extras/React.js +29 -30
- package/lib/helper/network/actions.js +33 -48
- package/lib/helper/network/utils.js +76 -83
- package/lib/helper/scripts/blurElement.js +6 -6
- package/lib/helper/scripts/focusElement.js +6 -6
- package/lib/helper/scripts/highlightElement.js +9 -9
- package/lib/helper/scripts/isElementClickable.js +34 -34
- package/lib/helper.js +2 -1
- package/lib/history.js +23 -20
- package/lib/hooks.js +10 -10
- package/lib/html.js +90 -100
- package/lib/index.js +48 -21
- package/lib/listener/config.js +8 -9
- package/lib/listener/emptyRun.js +6 -7
- package/lib/listener/exit.js +4 -3
- package/lib/listener/globalRetry.js +5 -5
- package/lib/listener/globalTimeout.js +11 -10
- package/lib/listener/helpers.js +33 -14
- package/lib/listener/mocha.js +3 -4
- package/lib/listener/result.js +4 -5
- package/lib/listener/steps.js +7 -18
- package/lib/listener/store.js +3 -3
- package/lib/locator.js +213 -192
- package/lib/mocha/asyncWrapper.js +108 -75
- package/lib/mocha/bdd.js +99 -13
- package/lib/mocha/cli.js +60 -27
- package/lib/mocha/factory.js +75 -19
- package/lib/mocha/featureConfig.js +1 -1
- package/lib/mocha/gherkin.js +57 -25
- package/lib/mocha/hooks.js +12 -3
- package/lib/mocha/index.js +13 -4
- package/lib/mocha/inject.js +22 -5
- package/lib/mocha/scenarioConfig.js +2 -2
- package/lib/mocha/suite.js +9 -2
- package/lib/mocha/test.js +10 -13
- package/lib/mocha/ui.js +28 -31
- package/lib/output.js +11 -9
- package/lib/parser.js +44 -44
- package/lib/pause.js +15 -16
- package/lib/plugin/analyze.js +19 -12
- package/lib/plugin/auth.js +20 -21
- package/lib/plugin/autoDelay.js +12 -8
- package/lib/plugin/coverage.js +12 -8
- package/lib/plugin/customLocator.js +3 -3
- package/lib/plugin/customReporter.js +3 -2
- package/lib/plugin/heal.js +14 -9
- package/lib/plugin/pageInfo.js +10 -10
- package/lib/plugin/pauseOnFail.js +4 -3
- package/lib/plugin/retryFailedStep.js +47 -5
- package/lib/plugin/screenshotOnFail.js +75 -37
- package/lib/plugin/stepByStepReport.js +14 -14
- package/lib/plugin/stepTimeout.js +4 -3
- package/lib/plugin/subtitles.js +6 -5
- package/lib/recorder.js +33 -23
- package/lib/rerun.js +69 -26
- package/lib/result.js +4 -4
- package/lib/secret.js +18 -17
- package/lib/session.js +95 -89
- package/lib/step/base.js +6 -6
- package/lib/step/config.js +1 -1
- package/lib/step/func.js +3 -3
- package/lib/step/helper.js +3 -3
- package/lib/step/meta.js +4 -4
- package/lib/step/record.js +11 -11
- package/lib/step/retry.js +3 -3
- package/lib/step/section.js +3 -3
- package/lib/step.js +7 -10
- package/lib/steps.js +9 -5
- package/lib/store.js +1 -1
- package/lib/timeout.js +1 -7
- package/lib/transform.js +8 -8
- package/lib/translation.js +32 -18
- package/lib/utils.js +68 -97
- package/lib/workerStorage.js +16 -17
- package/lib/workers.js +145 -171
- package/package.json +63 -57
- package/translations/de-DE.js +2 -2
- package/translations/fr-FR.js +2 -2
- package/translations/index.js +23 -10
- package/translations/it-IT.js +2 -2
- package/translations/ja-JP.js +2 -2
- package/translations/nl-NL.js +2 -2
- package/translations/pl-PL.js +2 -2
- package/translations/pt-BR.js +2 -2
- package/translations/ru-RU.js +2 -2
- package/translations/utils.js +11 -2
- package/translations/zh-CN.js +2 -2
- package/translations/zh-TW.js +2 -2
- package/typings/index.d.ts +7 -18
- package/typings/promiseBasedTypes.d.ts +3769 -5450
- package/typings/types.d.ts +3953 -5778
- package/bin/test-server.js +0 -53
- package/lib/element/WebElement.js +0 -327
- package/lib/helper/Nightmare.js +0 -1486
- package/lib/helper/Protractor.js +0 -1840
- package/lib/helper/TestCafe.js +0 -1391
- package/lib/helper/clientscripts/nightmare.js +0 -213
- package/lib/helper/extras/PlaywrightReactVueLocator.js +0 -43
- package/lib/helper/testcafe/testControllerHolder.js +0 -42
- package/lib/helper/testcafe/testcafe-utils.js +0 -61
- package/lib/listener/retryEnhancer.js +0 -85
- package/lib/plugin/allure.js +0 -15
- package/lib/plugin/autoLogin.js +0 -5
- package/lib/plugin/commentStep.js +0 -141
- package/lib/plugin/eachElement.js +0 -127
- package/lib/plugin/fakerTransform.js +0 -49
- package/lib/plugin/htmlReporter.js +0 -1947
- package/lib/plugin/retryTo.js +0 -16
- package/lib/plugin/selenoid.js +0 -364
- package/lib/plugin/standardActingHelpers.js +0 -6
- package/lib/plugin/tryTo.js +0 -16
- package/lib/plugin/wdio.js +0 -247
- package/lib/test-server.js +0 -323
- package/lib/within.js +0 -90
package/lib/codecept.js
CHANGED
|
@@ -1,15 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
|
|
1
|
+
import { existsSync, readFileSync } from 'fs'
|
|
2
|
+
import { globSync } from 'glob'
|
|
3
|
+
import fsPath from 'path'
|
|
4
|
+
import { resolve } from 'path'
|
|
5
|
+
import { fileURLToPath } from 'url'
|
|
6
|
+
import { dirname } from 'path'
|
|
7
|
+
import { createRequire } from 'module'
|
|
8
|
+
|
|
9
|
+
const __filename = fileURLToPath(import.meta.url)
|
|
10
|
+
const __dirname = dirname(__filename)
|
|
11
|
+
const require = createRequire(import.meta.url)
|
|
12
|
+
|
|
13
|
+
import Helper from '@codeceptjs/helper'
|
|
14
|
+
import container from './container.js'
|
|
15
|
+
import Config from './config.js'
|
|
16
|
+
import event from './event.js'
|
|
17
|
+
import runHook from './hooks.js'
|
|
18
|
+
import ActorFactory from './actor.js'
|
|
19
|
+
import output from './output.js'
|
|
20
|
+
import { emptyFolder } from './utils.js'
|
|
21
|
+
import { initCodeceptGlobals } from './globals.js'
|
|
22
|
+
|
|
23
|
+
import storeListener from './listener/store.js'
|
|
24
|
+
import stepsListener from './listener/steps.js'
|
|
25
|
+
import configListener from './listener/config.js'
|
|
26
|
+
import resultListener from './listener/result.js'
|
|
27
|
+
import helpersListener from './listener/helpers.js'
|
|
28
|
+
import globalTimeoutListener from './listener/globalTimeout.js'
|
|
29
|
+
import globalRetryListener from './listener/globalRetry.js'
|
|
30
|
+
import exitListener from './listener/exit.js'
|
|
31
|
+
import emptyRunListener from './listener/emptyRun.js'
|
|
13
32
|
|
|
14
33
|
/**
|
|
15
34
|
* CodeceptJS runner
|
|
@@ -52,11 +71,13 @@ class Codecept {
|
|
|
52
71
|
*
|
|
53
72
|
* @param {string} dir
|
|
54
73
|
*/
|
|
55
|
-
init(dir) {
|
|
56
|
-
this.initGlobals(dir)
|
|
74
|
+
async init(dir) {
|
|
75
|
+
await this.initGlobals(dir)
|
|
57
76
|
// initializing listeners
|
|
58
|
-
container.create(this.config, this.opts)
|
|
59
|
-
|
|
77
|
+
await container.create(this.config, this.opts)
|
|
78
|
+
// Store container globally for easy access
|
|
79
|
+
global.container = container
|
|
80
|
+
await this.runHooks()
|
|
60
81
|
}
|
|
61
82
|
|
|
62
83
|
/**
|
|
@@ -64,56 +85,24 @@ class Codecept {
|
|
|
64
85
|
*
|
|
65
86
|
* @param {string} dir
|
|
66
87
|
*/
|
|
67
|
-
initGlobals(dir) {
|
|
68
|
-
|
|
69
|
-
global.output_dir = fsPath.resolve(dir, this.config.output)
|
|
70
|
-
|
|
71
|
-
if (this.config.emptyOutputFolder) emptyFolder(global.output_dir)
|
|
72
|
-
|
|
73
|
-
if (!this.config.noGlobals) {
|
|
74
|
-
global.Helper = global.codecept_helper = require('@codeceptjs/helper')
|
|
75
|
-
global.actor = global.codecept_actor = require('./actor')
|
|
76
|
-
global.pause = require('./pause')
|
|
77
|
-
global.within = require('./within')
|
|
78
|
-
global.session = require('./session')
|
|
79
|
-
global.DataTable = require('./data/table')
|
|
80
|
-
global.locate = locator => require('./locator').build(locator)
|
|
81
|
-
global.inject = container.support
|
|
82
|
-
global.share = container.share
|
|
83
|
-
global.secret = require('./secret').secret
|
|
84
|
-
global.codecept_debug = output.debug
|
|
85
|
-
global.codeceptjs = require('./index') // load all objects
|
|
86
|
-
|
|
87
|
-
// BDD
|
|
88
|
-
const stepDefinitions = require('./mocha/bdd')
|
|
89
|
-
global.Given = stepDefinitions.Given
|
|
90
|
-
global.When = stepDefinitions.When
|
|
91
|
-
global.Then = stepDefinitions.Then
|
|
92
|
-
global.DefineParameterType = stepDefinitions.defineParameterType
|
|
93
|
-
|
|
94
|
-
// debug mode
|
|
95
|
-
global.debugMode = false
|
|
96
|
-
|
|
97
|
-
// mask sensitive data
|
|
98
|
-
global.maskSensitiveData = this.config.maskSensitiveData || false
|
|
99
|
-
}
|
|
88
|
+
async initGlobals(dir) {
|
|
89
|
+
await initCodeceptGlobals(dir, this.config, container)
|
|
100
90
|
}
|
|
101
91
|
|
|
102
92
|
/**
|
|
103
93
|
* Executes hooks.
|
|
104
94
|
*/
|
|
105
|
-
runHooks() {
|
|
95
|
+
async runHooks() {
|
|
106
96
|
// default hooks
|
|
107
|
-
runHook(
|
|
108
|
-
runHook(
|
|
109
|
-
runHook(
|
|
110
|
-
runHook(
|
|
111
|
-
runHook(
|
|
112
|
-
runHook(
|
|
113
|
-
runHook(
|
|
114
|
-
runHook(
|
|
115
|
-
runHook(
|
|
116
|
-
runHook(require('./listener/emptyRun'))
|
|
97
|
+
runHook(storeListener)
|
|
98
|
+
runHook(stepsListener)
|
|
99
|
+
runHook(configListener)
|
|
100
|
+
runHook(resultListener)
|
|
101
|
+
runHook(helpersListener)
|
|
102
|
+
runHook(globalTimeoutListener)
|
|
103
|
+
runHook(globalRetryListener)
|
|
104
|
+
runHook(exitListener)
|
|
105
|
+
runHook(emptyRunListener)
|
|
117
106
|
|
|
118
107
|
// custom hooks (previous iteration of plugins)
|
|
119
108
|
this.config.hooks.forEach(hook => runHook(hook))
|
|
@@ -158,7 +147,7 @@ class Codecept {
|
|
|
158
147
|
}
|
|
159
148
|
}
|
|
160
149
|
|
|
161
|
-
if (this.config.gherkin.features && !this.opts.tests) {
|
|
150
|
+
if (this.config.gherkin && this.config.gherkin.features && !this.opts.tests) {
|
|
162
151
|
if (Array.isArray(this.config.gherkin.features)) {
|
|
163
152
|
this.config.gherkin.features.forEach(feature => {
|
|
164
153
|
patterns.push(feature)
|
|
@@ -182,50 +171,6 @@ class Codecept {
|
|
|
182
171
|
})
|
|
183
172
|
}
|
|
184
173
|
}
|
|
185
|
-
|
|
186
|
-
if (this.opts.shuffle) {
|
|
187
|
-
this.testFiles = shuffle(this.testFiles)
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
if (this.opts.shard) {
|
|
191
|
-
this.testFiles = this._applySharding(this.testFiles, this.opts.shard)
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
/**
|
|
196
|
-
* Apply sharding to test files based on shard configuration
|
|
197
|
-
*
|
|
198
|
-
* @param {Array<string>} testFiles - Array of test file paths
|
|
199
|
-
* @param {string} shardConfig - Shard configuration in format "index/total" (e.g., "1/4")
|
|
200
|
-
* @returns {Array<string>} - Filtered array of test files for this shard
|
|
201
|
-
*/
|
|
202
|
-
_applySharding(testFiles, shardConfig) {
|
|
203
|
-
const shardMatch = shardConfig.match(/^(\d+)\/(\d+)$/)
|
|
204
|
-
if (!shardMatch) {
|
|
205
|
-
throw new Error('Invalid shard format. Expected format: "index/total" (e.g., "1/4")')
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
const shardIndex = parseInt(shardMatch[1], 10)
|
|
209
|
-
const shardTotal = parseInt(shardMatch[2], 10)
|
|
210
|
-
|
|
211
|
-
if (shardTotal < 1) {
|
|
212
|
-
throw new Error('Shard total must be at least 1')
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
if (shardIndex < 1 || shardIndex > shardTotal) {
|
|
216
|
-
throw new Error(`Shard index ${shardIndex} must be between 1 and ${shardTotal}`)
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
if (testFiles.length === 0) {
|
|
220
|
-
return testFiles
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
// Calculate which tests belong to this shard
|
|
224
|
-
const shardSize = Math.ceil(testFiles.length / shardTotal)
|
|
225
|
-
const startIndex = (shardIndex - 1) * shardSize
|
|
226
|
-
const endIndex = Math.min(startIndex + shardSize, testFiles.length)
|
|
227
|
-
|
|
228
|
-
return testFiles.slice(startIndex, endIndex)
|
|
229
174
|
}
|
|
230
175
|
|
|
231
176
|
/**
|
|
@@ -237,15 +182,29 @@ class Codecept {
|
|
|
237
182
|
async run(test) {
|
|
238
183
|
await container.started()
|
|
239
184
|
|
|
185
|
+
// Ensure translations are loaded for Gherkin features
|
|
186
|
+
try {
|
|
187
|
+
const { loadTranslations } = await import('./mocha/gherkin.js')
|
|
188
|
+
await loadTranslations()
|
|
189
|
+
} catch (e) {
|
|
190
|
+
// Ignore if gherkin module not available
|
|
191
|
+
}
|
|
192
|
+
|
|
240
193
|
return new Promise((resolve, reject) => {
|
|
241
194
|
const mocha = container.mocha()
|
|
242
195
|
mocha.files = this.testFiles
|
|
196
|
+
|
|
243
197
|
if (test) {
|
|
244
198
|
if (!fsPath.isAbsolute(test)) {
|
|
245
199
|
test = fsPath.join(global.codecept_dir, test)
|
|
246
200
|
}
|
|
247
|
-
|
|
201
|
+
const testBasename = fsPath.basename(test, '.js')
|
|
202
|
+
const testFeatureBasename = fsPath.basename(test, '.feature')
|
|
203
|
+
mocha.files = mocha.files.filter(t => {
|
|
204
|
+
return fsPath.basename(t, '.js') === testBasename || fsPath.basename(t, '.feature') === testFeatureBasename || t === test
|
|
205
|
+
})
|
|
248
206
|
}
|
|
207
|
+
|
|
249
208
|
const done = () => {
|
|
250
209
|
event.emit(event.all.result, container.result())
|
|
251
210
|
event.emit(event.all.after, this)
|
|
@@ -267,4 +226,4 @@ class Codecept {
|
|
|
267
226
|
}
|
|
268
227
|
}
|
|
269
228
|
|
|
270
|
-
|
|
229
|
+
export default Codecept
|
package/lib/colorUtils.js
CHANGED
|
@@ -144,14 +144,14 @@ function convertColorNameToHex(color) {
|
|
|
144
144
|
whitesmoke: '#f5f5f5',
|
|
145
145
|
yellow: '#ffff00',
|
|
146
146
|
yellowgreen: '#9acd32',
|
|
147
|
-
}
|
|
147
|
+
}
|
|
148
148
|
|
|
149
|
-
const cColor = `${color}`.toLowerCase()
|
|
149
|
+
const cColor = `${color}`.toLowerCase()
|
|
150
150
|
if (typeof colors[cColor] !== 'undefined') {
|
|
151
|
-
return colors[cColor]
|
|
151
|
+
return colors[cColor]
|
|
152
152
|
}
|
|
153
153
|
|
|
154
|
-
return color
|
|
154
|
+
return color
|
|
155
155
|
}
|
|
156
156
|
|
|
157
157
|
/**
|
|
@@ -160,23 +160,23 @@ function convertColorNameToHex(color) {
|
|
|
160
160
|
*/
|
|
161
161
|
function convertHexColorToRgba(hex) {
|
|
162
162
|
// Expand shorthand form (e.g. "#03F") to full form (e.g. "#0033FF")
|
|
163
|
-
const shorthandRegex = /^#([a-f\d])([a-f\d])([a-f\d])$/i
|
|
163
|
+
const shorthandRegex = /^#([a-f\d])([a-f\d])([a-f\d])$/i
|
|
164
164
|
const hexFull = `${hex}`.replace(shorthandRegex, (m, r, g, b) => {
|
|
165
|
-
return r + r + g + g + b + b
|
|
166
|
-
})
|
|
165
|
+
return r + r + g + g + b + b
|
|
166
|
+
})
|
|
167
167
|
|
|
168
|
-
const result = /^#([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hexFull)
|
|
168
|
+
const result = /^#([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hexFull)
|
|
169
169
|
if (!result) {
|
|
170
170
|
// Return untouched if not a hex code
|
|
171
|
-
return hex
|
|
171
|
+
return hex
|
|
172
172
|
}
|
|
173
173
|
|
|
174
|
-
const r = parseInt(result[1], 16)
|
|
175
|
-
const g = parseInt(result[2], 16)
|
|
176
|
-
const b = parseInt(result[3], 16)
|
|
177
|
-
const a = 1
|
|
174
|
+
const r = parseInt(result[1], 16)
|
|
175
|
+
const g = parseInt(result[2], 16)
|
|
176
|
+
const b = parseInt(result[3], 16)
|
|
177
|
+
const a = 1
|
|
178
178
|
|
|
179
|
-
return `rgba(${r}, ${g}, ${b}, ${a})
|
|
179
|
+
return `rgba(${r}, ${g}, ${b}, ${a})`
|
|
180
180
|
}
|
|
181
181
|
|
|
182
182
|
/**
|
|
@@ -190,29 +190,29 @@ function convertHexColorToRgba(hex) {
|
|
|
190
190
|
* @param {string} color Color as a string, i.e. rgb(85,0,0)
|
|
191
191
|
*/
|
|
192
192
|
function convertColorToRGBA(color) {
|
|
193
|
-
const cstr = `${color}`.toLowerCase().trim() || ''
|
|
193
|
+
const cstr = `${color}`.toLowerCase().trim() || ''
|
|
194
194
|
|
|
195
195
|
if (!/^rgba?\(.+?\)$/.test(cstr)) {
|
|
196
196
|
// Convert both color names and hex colors to rgba
|
|
197
|
-
const hexColor = convertColorNameToHex(color)
|
|
198
|
-
return convertHexColorToRgba(hexColor)
|
|
197
|
+
const hexColor = convertColorNameToHex(color)
|
|
198
|
+
return convertHexColorToRgba(hexColor)
|
|
199
199
|
}
|
|
200
200
|
|
|
201
201
|
// Convert rgb to rgba
|
|
202
|
-
const channels = cstr.match(/([\-0-9.]+)/g) || []
|
|
202
|
+
const channels = cstr.match(/([\-0-9.]+)/g) || []
|
|
203
203
|
|
|
204
204
|
switch (channels.length) {
|
|
205
205
|
case 3:
|
|
206
206
|
// Convert rgb to rgba
|
|
207
|
-
return `rgba(${channels.join(', ')}, 1)
|
|
207
|
+
return `rgba(${channels.join(', ')}, 1)`
|
|
208
208
|
|
|
209
209
|
case 4:
|
|
210
210
|
// Format rgba
|
|
211
|
-
return `rgba(${channels.join(', ')})
|
|
211
|
+
return `rgba(${channels.join(', ')})`
|
|
212
212
|
|
|
213
213
|
default:
|
|
214
214
|
// Unexpected color format. Leave it untouched (let the user handle it)
|
|
215
|
-
return color
|
|
215
|
+
return color
|
|
216
216
|
}
|
|
217
217
|
}
|
|
218
218
|
|
|
@@ -222,34 +222,32 @@ function convertColorToRGBA(color) {
|
|
|
222
222
|
* @param {string} prop CSS Property name
|
|
223
223
|
*/
|
|
224
224
|
function isColorProperty(prop) {
|
|
225
|
-
return
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
225
|
+
return (
|
|
226
|
+
[
|
|
227
|
+
'color',
|
|
228
|
+
'background',
|
|
229
|
+
'backgroundColor',
|
|
230
|
+
'background-color',
|
|
231
|
+
'borderColor',
|
|
232
|
+
'border-color',
|
|
233
|
+
'borderBottomColor',
|
|
234
|
+
'border-bottom-color',
|
|
235
|
+
'borderLeftColor',
|
|
236
|
+
'border-left-color',
|
|
237
|
+
'borderRightColor',
|
|
238
|
+
'borderTopColor',
|
|
239
|
+
'caretColor',
|
|
240
|
+
'columnRuleColor',
|
|
241
|
+
'outlineColor',
|
|
242
|
+
'textDecorationColor',
|
|
243
|
+
'border-right-color',
|
|
244
|
+
'border-top-color',
|
|
245
|
+
'caret-color',
|
|
246
|
+
'column-rule-color',
|
|
247
|
+
'outline-color',
|
|
248
|
+
'text-decoration-color',
|
|
249
|
+
].indexOf(prop) > -1
|
|
250
|
+
)
|
|
249
251
|
}
|
|
250
252
|
|
|
251
|
-
|
|
252
|
-
isColorProperty,
|
|
253
|
-
convertColorToRGBA,
|
|
254
|
-
convertColorNameToHex,
|
|
255
|
-
};
|
|
253
|
+
export { isColorProperty, convertColorToRGBA, convertColorNameToHex }
|
package/lib/command/check.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import { getConfig, getTestRoot } from './utils.js'
|
|
2
|
+
import Codecept from '../codecept.js'
|
|
3
|
+
import output from '../output.js'
|
|
4
|
+
import store from '../store.js'
|
|
5
|
+
import Container from '../container.js'
|
|
6
|
+
import figures from 'figures'
|
|
7
|
+
import chalk from 'chalk'
|
|
8
|
+
import { createTest } from '../mocha/test.js'
|
|
9
|
+
import { getMachineInfo } from './info.js'
|
|
10
|
+
import definitions from './definitions.js'
|
|
11
|
+
|
|
12
|
+
export default async function (options) {
|
|
13
13
|
const configFile = options.config
|
|
14
14
|
|
|
15
15
|
setTimeout(() => {
|
|
@@ -31,10 +31,10 @@ module.exports = async function (options) {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
const testRoot = getTestRoot(configFile)
|
|
34
|
-
let config = getConfig(configFile)
|
|
34
|
+
let config = await getConfig(configFile)
|
|
35
35
|
|
|
36
36
|
try {
|
|
37
|
-
config = getConfig(configFile)
|
|
37
|
+
config = await getConfig(configFile)
|
|
38
38
|
checks['config'] = true
|
|
39
39
|
} catch (err) {
|
|
40
40
|
checks['config'] = err
|
|
@@ -45,14 +45,14 @@ module.exports = async function (options) {
|
|
|
45
45
|
let codecept
|
|
46
46
|
try {
|
|
47
47
|
codecept = new Codecept(config, options)
|
|
48
|
-
codecept.init(testRoot)
|
|
49
|
-
await
|
|
48
|
+
await codecept.init(testRoot)
|
|
49
|
+
await Container.started()
|
|
50
50
|
checks.container = true
|
|
51
51
|
} catch (err) {
|
|
52
52
|
checks.container = err
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
const standardActingHelpers =
|
|
55
|
+
const standardActingHelpers = Container.STANDARD_ACTING_HELPERS
|
|
56
56
|
|
|
57
57
|
printCheck('container', checks['container'])
|
|
58
58
|
|
|
@@ -70,12 +70,17 @@ module.exports = async function (options) {
|
|
|
70
70
|
if (codecept) {
|
|
71
71
|
try {
|
|
72
72
|
codecept.loadTests()
|
|
73
|
-
const
|
|
74
|
-
mocha
|
|
73
|
+
const files = codecept.testFiles
|
|
74
|
+
const mocha = Container.mocha()
|
|
75
|
+
mocha.files = files
|
|
75
76
|
mocha.loadFiles()
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
|
|
78
|
+
for (const suite of mocha.suite.suites) {
|
|
79
|
+
if (suite && suite.tests) {
|
|
80
|
+
numTests += suite.tests.length
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
79
84
|
if (numTests > 0) {
|
|
80
85
|
checks.tests = true
|
|
81
86
|
} else {
|
|
@@ -97,13 +102,13 @@ module.exports = async function (options) {
|
|
|
97
102
|
|
|
98
103
|
store.dryRun = true
|
|
99
104
|
|
|
100
|
-
const helpers =
|
|
105
|
+
const helpers = Container.helpers()
|
|
101
106
|
|
|
102
107
|
try {
|
|
103
108
|
if (!Object.keys(helpers).length) throw new Error('No helpers found')
|
|
104
109
|
// load helpers
|
|
105
110
|
for (const helper of Object.values(helpers)) {
|
|
106
|
-
if (helper._init) helper._init()
|
|
111
|
+
if (helper._init) await helper._init()
|
|
107
112
|
}
|
|
108
113
|
checks.helpers = true
|
|
109
114
|
} catch (err) {
|
|
@@ -112,7 +117,7 @@ module.exports = async function (options) {
|
|
|
112
117
|
|
|
113
118
|
printCheck('helpers', checks['helpers'], `${Object.keys(helpers).join(', ')}`)
|
|
114
119
|
|
|
115
|
-
const pageObjects =
|
|
120
|
+
const pageObjects = Container.support()
|
|
116
121
|
|
|
117
122
|
try {
|
|
118
123
|
if (Object.keys(pageObjects).length) {
|
|
@@ -127,10 +132,10 @@ module.exports = async function (options) {
|
|
|
127
132
|
printCheck('page objects', checks['pageObjects'], `Total: ${Object.keys(pageObjects).length} support objects`)
|
|
128
133
|
|
|
129
134
|
checks.plugins = true // how to check plugins?
|
|
130
|
-
printCheck('plugins', checks['plugins'], Object.keys(
|
|
135
|
+
printCheck('plugins', checks['plugins'], Object.keys(Container.plugins()).join(', '))
|
|
131
136
|
|
|
132
137
|
if (Object.keys(helpers).length) {
|
|
133
|
-
const suite =
|
|
138
|
+
const suite = Container.mocha().suite
|
|
134
139
|
const test = createTest('test', () => {})
|
|
135
140
|
checks.setup = true
|
|
136
141
|
for (const helper of Object.values(helpers)) {
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import colors from 'chalk'
|
|
2
|
+
import fs from 'fs'
|
|
3
|
+
import inquirer from 'inquirer'
|
|
4
|
+
import { mkdirp } from 'mkdirp'
|
|
5
|
+
import path from 'path'
|
|
6
|
+
import util from 'util'
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
const {
|
|
10
|
-
|
|
8
|
+
import output from '../output.js'
|
|
9
|
+
const { print, success, error } = output
|
|
10
|
+
import { fileExists } from '../utils.js'
|
|
11
|
+
import { getTestRoot } from './utils.js'
|
|
11
12
|
|
|
12
|
-
|
|
13
|
+
export default function (initPath) {
|
|
13
14
|
const testsPath = getTestRoot(initPath)
|
|
14
15
|
|
|
15
16
|
print()
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import fs from 'fs'
|
|
2
|
+
import path from 'path'
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
import { getConfig, getTestRoot } from './utils.js'
|
|
5
|
+
import Codecept from '../codecept.js'
|
|
6
|
+
import container from '../container.js'
|
|
7
|
+
import output from '../output.js'
|
|
8
8
|
const actingHelpers = [...container.STANDARD_ACTING_HELPERS, 'REST']
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -86,11 +86,11 @@ const helperNames = []
|
|
|
86
86
|
/** @type {Array<string>} */
|
|
87
87
|
const customHelpers = []
|
|
88
88
|
|
|
89
|
-
|
|
89
|
+
export default async function (genPath, options) {
|
|
90
90
|
const configFile = options.config || genPath
|
|
91
91
|
/** @type {string} */
|
|
92
92
|
const testsPath = getTestRoot(configFile)
|
|
93
|
-
const config = getConfig(configFile)
|
|
93
|
+
const config = await getConfig(configFile)
|
|
94
94
|
if (!config) return
|
|
95
95
|
|
|
96
96
|
/** @type {Object<string, string>} */
|
|
@@ -106,7 +106,8 @@ module.exports = function (genPath, options) {
|
|
|
106
106
|
const targetFolderPath = (options.output && getTestRoot(options.output)) || testsPath
|
|
107
107
|
|
|
108
108
|
const codecept = new Codecept(config, {})
|
|
109
|
-
codecept.init(testsPath)
|
|
109
|
+
await codecept.init(testsPath)
|
|
110
|
+
await container.started()
|
|
110
111
|
|
|
111
112
|
const helpers = container.helpers()
|
|
112
113
|
const translations = container.translation()
|
|
@@ -229,7 +230,12 @@ function getImportString(testsPath, targetFolderPath, pathsToType, pathsToValue)
|
|
|
229
230
|
|
|
230
231
|
for (const name in pathsToType) {
|
|
231
232
|
const relativePath = getPath(pathsToType[name], targetFolderPath, testsPath)
|
|
232
|
-
|
|
233
|
+
// For ESM modules with default exports, we need to access the default export type
|
|
234
|
+
if (relativePath.endsWith('.js')) {
|
|
235
|
+
importStrings.push(`type ${name} = typeof import('${relativePath}')['default'];`)
|
|
236
|
+
} else {
|
|
237
|
+
importStrings.push(`type ${name} = typeof import('${relativePath}');`)
|
|
238
|
+
}
|
|
233
239
|
}
|
|
234
240
|
|
|
235
241
|
for (const name in pathsToValue) {
|
package/lib/command/dryRun.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { getConfig, getTestRoot } from './utils.js'
|
|
2
|
+
import Config from '../config.js'
|
|
3
|
+
import Codecept from '../codecept.js'
|
|
4
|
+
import output from '../output.js'
|
|
5
|
+
import event from '../event.js'
|
|
6
|
+
import store from '../store.js'
|
|
7
|
+
import Container from '../container.js'
|
|
8
|
+
|
|
9
|
+
export default async function (test, options) {
|
|
10
10
|
if (options.grep) process.env.grep = options.grep
|
|
11
11
|
const configFile = options.config
|
|
12
12
|
let codecept
|
|
13
13
|
|
|
14
14
|
const testRoot = getTestRoot(configFile)
|
|
15
|
-
let config = getConfig(configFile)
|
|
15
|
+
let config = await getConfig(configFile)
|
|
16
16
|
if (options.override) {
|
|
17
17
|
config = Config.append(JSON.parse(options.override))
|
|
18
18
|
}
|
|
@@ -27,7 +27,7 @@ module.exports = async function (test, options) {
|
|
|
27
27
|
|
|
28
28
|
try {
|
|
29
29
|
codecept = new Codecept(config, options)
|
|
30
|
-
codecept.init(testRoot)
|
|
30
|
+
await codecept.init(testRoot)
|
|
31
31
|
|
|
32
32
|
if (options.bootstrap) await codecept.bootstrap()
|
|
33
33
|
|
|
@@ -35,20 +35,20 @@ module.exports = async function (test, options) {
|
|
|
35
35
|
store.dryRun = true
|
|
36
36
|
|
|
37
37
|
if (!options.steps && !options.verbose && !options.debug) {
|
|
38
|
-
printTests(codecept.testFiles)
|
|
38
|
+
await printTests(codecept.testFiles)
|
|
39
39
|
return
|
|
40
40
|
}
|
|
41
41
|
event.dispatcher.on(event.all.result, printFooter)
|
|
42
|
-
codecept.run(test)
|
|
42
|
+
await codecept.run(test)
|
|
43
43
|
} catch (err) {
|
|
44
44
|
console.error(err)
|
|
45
45
|
process.exit(1)
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
function printTests(files) {
|
|
50
|
-
const figures =
|
|
51
|
-
const colors =
|
|
49
|
+
async function printTests(files) {
|
|
50
|
+
const { default: figures } = await import('figures')
|
|
51
|
+
const { default: colors } = await import('chalk')
|
|
52
52
|
|
|
53
53
|
output.print(output.styles.debug(`Tests from ${global.codecept_dir}:`))
|
|
54
54
|
output.print()
|