codeceptjs 3.7.6-beta.4 → 4.0.0-beta.10.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 +1 -3
- package/bin/codecept.js +51 -53
- package/bin/test-server.js +14 -3
- package/docs/webapi/click.mustache +5 -1
- package/lib/actor.js +15 -11
- package/lib/ai.js +72 -107
- 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 +102 -75
- 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 +62 -27
- 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 +36 -29
- 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 +24 -9
- package/lib/command/run.js +23 -8
- package/lib/command/utils.js +20 -18
- package/lib/command/workers/runTests.js +197 -114
- package/lib/config.js +124 -51
- package/lib/container.js +438 -87
- 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/element/WebElement.js +2 -2
- 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 +11 -11
- package/lib/helper/ApiDataFactory.js +50 -19
- package/lib/helper/Appium.js +19 -27
- package/lib/helper/FileSystem.js +32 -12
- package/lib/helper/GraphQL.js +3 -3
- package/lib/helper/GraphQLDataFactory.js +4 -4
- package/lib/helper/JSONResponse.js +25 -29
- package/lib/helper/Mochawesome.js +7 -4
- package/lib/helper/Playwright.js +902 -164
- package/lib/helper/Puppeteer.js +383 -76
- package/lib/helper/REST.js +29 -12
- package/lib/helper/WebDriver.js +268 -61
- package/lib/helper/clientscripts/PollyWebDriverExt.js +1 -1
- 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/PlaywrightReactVueLocator.js +18 -9
- package/lib/helper/extras/PlaywrightRestartOpts.js +34 -23
- package/lib/helper/extras/Popup.js +1 -1
- package/lib/helper/extras/React.js +29 -30
- package/lib/helper/network/actions.js +29 -44
- 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 +19 -12
- package/lib/listener/emptyRun.js +6 -7
- package/lib/listener/enhancedGlobalRetry.js +6 -6
- package/lib/listener/exit.js +4 -3
- package/lib/listener/globalRetry.js +5 -5
- package/lib/listener/globalTimeout.js +30 -14
- package/lib/listener/helpers.js +39 -14
- package/lib/listener/mocha.js +3 -4
- package/lib/listener/result.js +4 -5
- package/lib/listener/retryEnhancer.js +3 -3
- package/lib/listener/steps.js +8 -7
- package/lib/listener/store.js +3 -3
- package/lib/locator.js +213 -192
- package/lib/mocha/asyncWrapper.js +105 -62
- package/lib/mocha/bdd.js +99 -13
- package/lib/mocha/cli.js +59 -26
- package/lib/mocha/factory.js +78 -19
- package/lib/mocha/featureConfig.js +1 -1
- package/lib/mocha/gherkin.js +56 -24
- 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 -7
- package/lib/mocha/ui.js +28 -18
- package/lib/output.js +10 -8
- 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 +28 -11
- package/lib/plugin/customLocator.js +3 -3
- package/lib/plugin/customReporter.js +3 -2
- package/lib/plugin/enhancedRetryFailedStep.js +6 -6
- package/lib/plugin/heal.js +14 -9
- package/lib/plugin/htmlReporter.js +724 -99
- package/lib/plugin/pageInfo.js +10 -10
- package/lib/plugin/pauseOnFail.js +4 -3
- package/lib/plugin/retryFailedStep.js +48 -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 -14
- package/lib/rerun.js +69 -26
- package/lib/result.js +4 -4
- package/lib/retryCoordinator.js +2 -2
- package/lib/secret.js +18 -17
- package/lib/session.js +95 -89
- package/lib/step/base.js +7 -7
- package/lib/step/comment.js +2 -2
- 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 +5 -5
- 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/template/heal.js +1 -1
- package/lib/template/prompts/generatePageObject.js +31 -0
- package/lib/template/prompts/healStep.js +13 -0
- package/lib/template/prompts/writeStep.js +9 -0
- package/lib/test-server.js +17 -6
- package/lib/timeout.js +1 -7
- package/lib/transform.js +8 -8
- package/lib/translation.js +32 -18
- package/lib/utils/mask_data.js +4 -10
- package/lib/utils.js +66 -64
- package/lib/workerStorage.js +17 -17
- package/lib/workers.js +214 -84
- package/package.json +41 -37
- 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 +4 -3
- package/translations/zh-CN.js +2 -2
- package/translations/zh-TW.js +2 -2
- package/typings/index.d.ts +5 -3
- package/typings/promiseBasedTypes.d.ts +4 -0
- package/typings/types.d.ts +4 -0
- 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/testcafe/testControllerHolder.js +0 -42
- package/lib/helper/testcafe/testcafe-utils.js +0 -61
- 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/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/within.js +0 -90
package/lib/mocha/gherkin.js
CHANGED
|
@@ -1,28 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
import Gherkin from '@cucumber/gherkin'
|
|
2
|
+
import { IdGenerator } from '@cucumber/messages'
|
|
3
|
+
import { Context, Suite } from 'mocha'
|
|
4
|
+
import debug from 'debug'
|
|
5
|
+
const debugBdd = debug('codeceptjs:bdd')
|
|
6
|
+
|
|
7
|
+
import event from '../event.js'
|
|
8
|
+
import { injected, setup, teardown, suiteSetup, suiteTeardown } from './asyncWrapper.js'
|
|
9
|
+
import step from '../step/base.js'
|
|
10
|
+
import MetaStep from '../step/meta.js'
|
|
11
|
+
import DataTableArgument from '../data/dataTableArgument.js'
|
|
12
|
+
import transform from '../transform.js'
|
|
13
|
+
import { enhanceMochaSuite } from './suite.js'
|
|
14
|
+
import { createTest } from './test.js'
|
|
15
|
+
import { matchStep } from './bdd.js'
|
|
16
|
+
|
|
17
|
+
const uuidFn = IdGenerator.uuid()
|
|
16
18
|
const builder = new Gherkin.AstBuilder(uuidFn)
|
|
17
19
|
const matcher = new Gherkin.GherkinClassicTokenMatcher()
|
|
18
20
|
const parser = new Gherkin.Parser(builder, matcher)
|
|
19
21
|
parser.stopAtFirstError = false
|
|
20
22
|
|
|
21
|
-
|
|
23
|
+
const gherkinParser = (text, file) => {
|
|
22
24
|
const ast = parser.parse(text)
|
|
23
25
|
let currentLanguage
|
|
24
26
|
|
|
25
27
|
if (ast.feature) {
|
|
28
|
+
// Ensure translations are loaded before trying to access them
|
|
26
29
|
currentLanguage = getTranslation(ast.feature.language)
|
|
27
30
|
}
|
|
28
31
|
|
|
@@ -39,14 +42,20 @@ module.exports = (text, file) => {
|
|
|
39
42
|
suite.file = file
|
|
40
43
|
suite.timeout(0)
|
|
41
44
|
|
|
42
|
-
suite.beforeEach('codeceptjs.before', ()
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
suite.beforeEach('codeceptjs.before', function () {
|
|
46
|
+
// In Mocha, 'this' refers to the current test in beforeEach/afterEach hooks
|
|
47
|
+
setup(this)(() => {})
|
|
48
|
+
})
|
|
49
|
+
suite.afterEach('codeceptjs.after', function () {
|
|
50
|
+
// In Mocha, 'this' refers to the current test in beforeEach/afterEach hooks
|
|
51
|
+
teardown(this)(() => {})
|
|
52
|
+
})
|
|
53
|
+
suite.beforeAll('codeceptjs.beforeSuite', suiteSetup(suite))
|
|
54
|
+
suite.afterAll('codeceptjs.afterSuite', suiteTeardown(suite))
|
|
46
55
|
|
|
47
56
|
const runSteps = async steps => {
|
|
48
57
|
for (const step of steps) {
|
|
49
|
-
const metaStep = new
|
|
58
|
+
const metaStep = new MetaStep(null, step.text)
|
|
50
59
|
metaStep.actor = step.keyword.trim()
|
|
51
60
|
let helperStep
|
|
52
61
|
const setMetaStep = step => {
|
|
@@ -184,16 +193,39 @@ function addExampleInTable(exampleSteps, placeholders) {
|
|
|
184
193
|
return steps
|
|
185
194
|
}
|
|
186
195
|
|
|
196
|
+
// Import translations at module level to avoid async in parser
|
|
197
|
+
let translations = null
|
|
198
|
+
async function loadTranslations() {
|
|
199
|
+
if (!translations) {
|
|
200
|
+
// Import container to ensure it's initialized
|
|
201
|
+
const Container = await import('../container.js')
|
|
202
|
+
await Container.default.started()
|
|
203
|
+
|
|
204
|
+
// Now load translations
|
|
205
|
+
const translationsModule = await import('../../translations/index.js')
|
|
206
|
+
translations = translationsModule.default || translationsModule
|
|
207
|
+
}
|
|
208
|
+
return translations
|
|
209
|
+
}
|
|
210
|
+
|
|
187
211
|
function getTranslation(language) {
|
|
188
|
-
|
|
212
|
+
if (!translations) {
|
|
213
|
+
// Translations not loaded yet, return null (will use default)
|
|
214
|
+
return null
|
|
215
|
+
}
|
|
189
216
|
|
|
190
|
-
|
|
217
|
+
const translationKeys = Object.keys(translations)
|
|
218
|
+
for (const availableTranslation of translationKeys) {
|
|
191
219
|
if (!language) {
|
|
192
220
|
break
|
|
193
221
|
}
|
|
194
222
|
|
|
195
223
|
if (availableTranslation.includes(language)) {
|
|
196
|
-
return
|
|
224
|
+
return translations[availableTranslation]
|
|
197
225
|
}
|
|
198
226
|
}
|
|
227
|
+
return null
|
|
199
228
|
}
|
|
229
|
+
|
|
230
|
+
export { loadTranslations }
|
|
231
|
+
export default gherkinParser
|
package/lib/mocha/hooks.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import event from '../event.js'
|
|
2
|
+
import { serializeError } from '../utils.js'
|
|
3
3
|
// const { serializeTest } = require('./test')
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -102,7 +102,16 @@ class HookConfig {
|
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
-
|
|
105
|
+
export {
|
|
106
|
+
BeforeHook,
|
|
107
|
+
AfterHook,
|
|
108
|
+
BeforeSuiteHook,
|
|
109
|
+
AfterSuiteHook,
|
|
110
|
+
fireHook,
|
|
111
|
+
HookConfig,
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export default {
|
|
106
115
|
BeforeHook,
|
|
107
116
|
AfterHook,
|
|
108
117
|
BeforeSuiteHook,
|
package/lib/mocha/index.js
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import Suite from 'mocha/lib/suite.js'
|
|
2
|
+
import Test from 'mocha/lib/test.js'
|
|
3
|
+
import { BeforeHook, AfterHook, BeforeSuiteHook, AfterSuiteHook } from './hooks.js'
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
export {
|
|
6
|
+
Suite,
|
|
7
|
+
Test,
|
|
8
|
+
BeforeHook,
|
|
9
|
+
AfterHook,
|
|
10
|
+
BeforeSuiteHook,
|
|
11
|
+
AfterSuiteHook,
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export default {
|
|
6
15
|
Suite,
|
|
7
16
|
Test,
|
|
8
17
|
BeforeHook,
|
package/lib/mocha/inject.js
CHANGED
|
@@ -1,13 +1,30 @@
|
|
|
1
|
-
|
|
1
|
+
import { getParams } from '../parser.js'
|
|
2
|
+
|
|
3
|
+
const getInjectedArguments = async (fn, test, suite) => {
|
|
4
|
+
const containerModule = await import('../container.js')
|
|
5
|
+
const container = containerModule.default || containerModule
|
|
2
6
|
|
|
3
|
-
const getInjectedArguments = (fn, test) => {
|
|
4
|
-
const container = require('../container')
|
|
5
7
|
const testArgs = {}
|
|
6
|
-
const params =
|
|
8
|
+
const params = getParams(fn) || []
|
|
7
9
|
const objects = container.support()
|
|
8
10
|
|
|
9
11
|
for (const key of params) {
|
|
10
12
|
testArgs[key] = {}
|
|
13
|
+
|
|
14
|
+
// Handle special built-in objects first
|
|
15
|
+
if (key === 'suite') {
|
|
16
|
+
if (test) {
|
|
17
|
+
testArgs[key] = test.parent || test
|
|
18
|
+
} else if (suite) {
|
|
19
|
+
testArgs[key] = suite
|
|
20
|
+
}
|
|
21
|
+
continue
|
|
22
|
+
}
|
|
23
|
+
if (key === 'test') {
|
|
24
|
+
testArgs[key] = test
|
|
25
|
+
continue
|
|
26
|
+
}
|
|
27
|
+
|
|
11
28
|
if (test && test.inject && test.inject[key]) {
|
|
12
29
|
// @FIX: need fix got inject
|
|
13
30
|
testArgs[key] = test.inject[key]
|
|
@@ -26,4 +43,4 @@ const getInjectedArguments = (fn, test) => {
|
|
|
26
43
|
return testArgs
|
|
27
44
|
}
|
|
28
45
|
|
|
29
|
-
|
|
46
|
+
export { getInjectedArguments }
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { isAsyncFunction } from '../utils.js'
|
|
2
2
|
|
|
3
3
|
/** @class */
|
|
4
4
|
class ScenarioConfig {
|
|
@@ -135,4 +135,4 @@ class ScenarioConfig {
|
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
137
|
|
|
138
|
-
|
|
138
|
+
export default ScenarioConfig
|
package/lib/mocha/suite.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import MochaSuite from 'mocha/lib/suite.js'
|
|
2
2
|
/**
|
|
3
3
|
* @typedef {import('mocha')} Mocha
|
|
4
4
|
*/
|
|
@@ -74,7 +74,14 @@ function deserializeSuite(suite) {
|
|
|
74
74
|
return suite
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
|
|
77
|
+
export {
|
|
78
|
+
createSuite,
|
|
79
|
+
enhanceMochaSuite,
|
|
80
|
+
serializeSuite,
|
|
81
|
+
deserializeSuite,
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export default {
|
|
78
85
|
createSuite,
|
|
79
86
|
enhanceMochaSuite,
|
|
80
87
|
serializeSuite,
|
package/lib/mocha/test.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import Test from 'mocha/lib/test.js'
|
|
2
|
+
import Suite from 'mocha/lib/suite.js'
|
|
3
|
+
import { genTestId, serializeError, clearString, relativeDir } from '../utils.js'
|
|
4
|
+
import Step from '../step/base.js'
|
|
5
|
+
import { enhanceMochaSuite } from './suite.js'
|
|
6
|
+
import { test as testWrapper } from './asyncWrapper.js'
|
|
7
7
|
/**
|
|
8
8
|
* Factory function to create enhanced tests
|
|
9
9
|
* @param {string} title - Test title
|
|
@@ -47,6 +47,7 @@ function enhanceMochaTest(test) {
|
|
|
47
47
|
*/
|
|
48
48
|
test.addToSuite = function (suite) {
|
|
49
49
|
enhanceMochaSuite(suite)
|
|
50
|
+
// Get testWrapper from asyncWrapper module
|
|
50
51
|
suite.addTest(testWrapper(this))
|
|
51
52
|
if (test.file && !suite.file) suite.file = test.file
|
|
52
53
|
test.tags = [...(test.tags || []), ...(suite.tags || [])]
|
|
@@ -171,7 +172,9 @@ function testToFileName(test, { suffix = '', unique = false } = {}) {
|
|
|
171
172
|
return fileName
|
|
172
173
|
}
|
|
173
174
|
|
|
174
|
-
|
|
175
|
+
export { createTest, testToFileName, enhanceMochaTest, serializeTest, deserializeTest, cloneTest }
|
|
176
|
+
|
|
177
|
+
export default {
|
|
175
178
|
createTest,
|
|
176
179
|
testToFileName,
|
|
177
180
|
enhanceMochaTest,
|
package/lib/mocha/ui.js
CHANGED
|
@@ -1,15 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import escapeRe from 'escape-string-regexp'
|
|
2
|
+
import { test, setup, teardown, suiteSetup, suiteTeardown, injected } from './asyncWrapper.js'
|
|
3
|
+
import ScenarioConfig from './scenarioConfig.js'
|
|
4
|
+
import FeatureConfig from './featureConfig.js'
|
|
5
|
+
import addDataContext from '../data/context.js'
|
|
6
|
+
import { createTest } from './test.js'
|
|
7
|
+
import { createSuite } from './suite.js'
|
|
8
|
+
import { HookConfig, AfterSuiteHook, AfterHook, BeforeSuiteHook, BeforeHook } from './hooks.js'
|
|
9
|
+
import { initMochaGlobals } from '../globals.js'
|
|
10
|
+
import common from 'mocha/lib/interfaces/common.js'
|
|
11
|
+
import container from '../container.js'
|
|
9
12
|
|
|
10
13
|
const setContextTranslation = context => {
|
|
11
|
-
|
|
12
|
-
const
|
|
14
|
+
// Try global container first, then local container instance
|
|
15
|
+
const containerToUse = global.container || container
|
|
16
|
+
if (!containerToUse) return
|
|
17
|
+
|
|
18
|
+
const translation = containerToUse.translation?.() || containerToUse.translation
|
|
19
|
+
const contexts = translation?.value?.('contexts')
|
|
13
20
|
|
|
14
21
|
if (contexts) {
|
|
15
22
|
for (const key of Object.keys(contexts)) {
|
|
@@ -34,7 +41,7 @@ const setContextTranslation = context => {
|
|
|
34
41
|
* @param {Mocha.Suite} suite Root suite.
|
|
35
42
|
* @ignore
|
|
36
43
|
*/
|
|
37
|
-
|
|
44
|
+
export default function (suite) {
|
|
38
45
|
const suites = [suite]
|
|
39
46
|
suite.timeout(0)
|
|
40
47
|
let afterAllHooks
|
|
@@ -43,7 +50,7 @@ module.exports = function (suite) {
|
|
|
43
50
|
let afterEachHooksAreLoaded
|
|
44
51
|
|
|
45
52
|
suite.on('pre-require', (context, file, mocha) => {
|
|
46
|
-
const
|
|
53
|
+
const cmn = common(suites, context, mocha)
|
|
47
54
|
|
|
48
55
|
const addScenario = function (title, opts = {}, fn) {
|
|
49
56
|
const suite = suites[0]
|
|
@@ -65,8 +72,8 @@ module.exports = function (suite) {
|
|
|
65
72
|
|
|
66
73
|
// create dispatcher
|
|
67
74
|
|
|
68
|
-
context.BeforeAll =
|
|
69
|
-
context.AfterAll =
|
|
75
|
+
context.BeforeAll = cmn.before
|
|
76
|
+
context.AfterAll = cmn.after
|
|
70
77
|
|
|
71
78
|
context.run = mocha.options.delay && common.runWithSuite(suite)
|
|
72
79
|
/**
|
|
@@ -94,11 +101,11 @@ module.exports = function (suite) {
|
|
|
94
101
|
|
|
95
102
|
suite.file = file
|
|
96
103
|
suites.unshift(suite)
|
|
97
|
-
suite.beforeEach('codeceptjs.before',
|
|
98
|
-
afterEachHooks.push(['finalize codeceptjs',
|
|
104
|
+
suite.beforeEach('codeceptjs.before', setup(suite))
|
|
105
|
+
afterEachHooks.push(['finalize codeceptjs', teardown(suite)])
|
|
99
106
|
|
|
100
|
-
suite.beforeAll('codeceptjs.beforeSuite',
|
|
101
|
-
afterAllHooks.push(['codeceptjs.afterSuite',
|
|
107
|
+
suite.beforeAll('codeceptjs.beforeSuite', suiteSetup(suite))
|
|
108
|
+
afterAllHooks.push(['codeceptjs.afterSuite', suiteTeardown(suite)])
|
|
102
109
|
|
|
103
110
|
return new FeatureConfig(suite)
|
|
104
111
|
}
|
|
@@ -208,6 +215,9 @@ module.exports = function (suite) {
|
|
|
208
215
|
|
|
209
216
|
setContextTranslation(context)
|
|
210
217
|
|
|
218
|
+
// Initialize all globals
|
|
219
|
+
initMochaGlobals(context)
|
|
220
|
+
|
|
211
221
|
addDataContext(context)
|
|
212
222
|
})
|
|
213
223
|
|
package/lib/output.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import colors from 'chalk'
|
|
2
|
+
import figures from 'figures'
|
|
3
|
+
import { maskData, shouldMaskData, getMaskConfig } from './utils/mask_data.js'
|
|
4
4
|
|
|
5
5
|
const styles = {
|
|
6
6
|
error: colors.bgRed.white.bold,
|
|
@@ -21,7 +21,7 @@ let newline = true
|
|
|
21
21
|
* @alias output
|
|
22
22
|
* @namespace
|
|
23
23
|
*/
|
|
24
|
-
|
|
24
|
+
const output = {
|
|
25
25
|
colors,
|
|
26
26
|
styles,
|
|
27
27
|
print,
|
|
@@ -94,7 +94,7 @@ module.exports = {
|
|
|
94
94
|
debug(msg) {
|
|
95
95
|
const _msg = shouldMaskData() ? maskData(msg, getMaskConfig()) : msg
|
|
96
96
|
if (outputLevel >= 2) {
|
|
97
|
-
print(' '.repeat(
|
|
97
|
+
print(' '.repeat(output.stepShift), styles.debug(`${figures.pointerSmall} ${_msg}`))
|
|
98
98
|
}
|
|
99
99
|
},
|
|
100
100
|
|
|
@@ -105,7 +105,7 @@ module.exports = {
|
|
|
105
105
|
log(msg) {
|
|
106
106
|
const _msg = shouldMaskData() ? maskData(msg, getMaskConfig()) : msg
|
|
107
107
|
if (outputLevel >= 3) {
|
|
108
|
-
print(' '.repeat(
|
|
108
|
+
print(' '.repeat(output.stepShift), styles.log(truncate(` ${_msg}`, output.stepShift)))
|
|
109
109
|
}
|
|
110
110
|
},
|
|
111
111
|
|
|
@@ -133,7 +133,7 @@ module.exports = {
|
|
|
133
133
|
* @param {string} msg
|
|
134
134
|
*/
|
|
135
135
|
plugin(pluginName, msg = '') {
|
|
136
|
-
|
|
136
|
+
output.debug(`<${pluginName}> ${msg}`)
|
|
137
137
|
},
|
|
138
138
|
|
|
139
139
|
/**
|
|
@@ -153,7 +153,7 @@ module.exports = {
|
|
|
153
153
|
let stepLine = step.toCliStyled ? step.toCliStyled() : step.toString()
|
|
154
154
|
if (step.metaStep && outputLevel >= 1) {
|
|
155
155
|
// this.stepShift += 2;
|
|
156
|
-
stepLine = colors.dim(truncate(stepLine,
|
|
156
|
+
stepLine = colors.dim(truncate(stepLine, output.stepShift))
|
|
157
157
|
}
|
|
158
158
|
if (step.comment) {
|
|
159
159
|
stepLine += colors.grey(step.comment.split('\n').join('\n' + ' '.repeat(4)))
|
|
@@ -304,6 +304,8 @@ module.exports = {
|
|
|
304
304
|
},
|
|
305
305
|
}
|
|
306
306
|
|
|
307
|
+
export default output
|
|
308
|
+
|
|
307
309
|
function print(...msg) {
|
|
308
310
|
if (outputProcess) {
|
|
309
311
|
msg.unshift(outputProcess)
|
package/lib/parser.js
CHANGED
|
@@ -1,74 +1,74 @@
|
|
|
1
|
-
function _interopDefault(ex) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
function _interopDefault(ex) {
|
|
2
|
+
return ex && typeof ex === 'object' && 'default' in ex ? ex.default : ex
|
|
3
|
+
}
|
|
4
|
+
import * as acorn from 'acorn'
|
|
5
|
+
import parseFunctionModule from 'parse-function'
|
|
6
|
+
const parseFunction = _interopDefault(parseFunctionModule)
|
|
7
|
+
const parser = parseFunction({ parse: acorn.parse, ecmaVersion: 11, plugins: ['objectRestSpread'] })
|
|
8
|
+
import output from './output.js'
|
|
5
9
|
|
|
6
|
-
parser.use(destructuredArgs)
|
|
10
|
+
parser.use(destructuredArgs)
|
|
7
11
|
|
|
8
|
-
|
|
9
|
-
const newFn = fn.toString().replace(/^async/, 'async function')
|
|
10
|
-
return getParams(newFn).join(', ')
|
|
11
|
-
}
|
|
12
|
+
export const getParamsToString = function (fn) {
|
|
13
|
+
const newFn = fn.toString().replace(/^async/, 'async function')
|
|
14
|
+
return getParams(newFn).join(', ')
|
|
15
|
+
}
|
|
12
16
|
|
|
13
17
|
function getParams(fn) {
|
|
14
|
-
if (fn.isSinonProxy) return []
|
|
18
|
+
if (fn.isSinonProxy) return []
|
|
15
19
|
try {
|
|
16
|
-
const reflected = parser.parse(fn)
|
|
20
|
+
const reflected = parser.parse(fn)
|
|
17
21
|
if (reflected.args.length > 1 || reflected.args[0] === 'I') {
|
|
18
|
-
error('Error: old CodeceptJS v2 format detected. Upgrade your project to the new format -> https://bit.ly/codecept3Up')
|
|
22
|
+
output.error('Error: old CodeceptJS v2 format detected. Upgrade your project to the new format -> https://bit.ly/codecept3Up')
|
|
19
23
|
}
|
|
20
|
-
if (reflected.destructuredArgs.length > 0) reflected.args = [...reflected.destructuredArgs]
|
|
21
|
-
const params = reflected.args.map(
|
|
22
|
-
const def = reflected.defaults[p]
|
|
24
|
+
if (reflected.destructuredArgs.length > 0) reflected.args = [...reflected.destructuredArgs]
|
|
25
|
+
const params = reflected.args.map(p => {
|
|
26
|
+
const def = reflected.defaults[p]
|
|
23
27
|
if (def) {
|
|
24
|
-
return `${p}=${def}
|
|
28
|
+
return `${p}=${def}`
|
|
25
29
|
}
|
|
26
|
-
return p
|
|
27
|
-
})
|
|
28
|
-
return params
|
|
30
|
+
return p
|
|
31
|
+
})
|
|
32
|
+
return params
|
|
29
33
|
} catch (err) {
|
|
30
|
-
console.log(`Error in ${fn.toString()}`)
|
|
31
|
-
error(err)
|
|
34
|
+
console.log(`Error in ${fn.toString()}`)
|
|
35
|
+
output.error(err)
|
|
32
36
|
}
|
|
33
37
|
}
|
|
34
38
|
|
|
35
|
-
|
|
39
|
+
export { getParams }
|
|
36
40
|
|
|
37
41
|
function destructuredArgs() {
|
|
38
42
|
return (node, result) => {
|
|
39
|
-
result.destructuredArgs = result.destructuredArgs || []
|
|
43
|
+
result.destructuredArgs = result.destructuredArgs || []
|
|
40
44
|
|
|
41
45
|
if (node.type === 'ObjectExpression' && node.properties.length > 0) {
|
|
42
|
-
node.properties.forEach(
|
|
46
|
+
node.properties.forEach(prop => {
|
|
43
47
|
if (prop.value && prop.value.params.length > 0) {
|
|
44
|
-
result.destructuredArgs = parseDestructuredArgs(prop.value)
|
|
48
|
+
result.destructuredArgs = parseDestructuredArgs(prop.value)
|
|
45
49
|
}
|
|
46
|
-
})
|
|
50
|
+
})
|
|
47
51
|
|
|
48
|
-
return result
|
|
52
|
+
return result
|
|
49
53
|
}
|
|
50
54
|
|
|
51
|
-
if (!Array.isArray(node.params)) return result
|
|
52
|
-
result.destructuredArgs = parseDestructuredArgs(node)
|
|
55
|
+
if (!Array.isArray(node.params)) return result
|
|
56
|
+
result.destructuredArgs = parseDestructuredArgs(node)
|
|
53
57
|
|
|
54
|
-
return result
|
|
55
|
-
}
|
|
58
|
+
return result
|
|
59
|
+
}
|
|
56
60
|
}
|
|
57
61
|
|
|
58
62
|
function parseDestructuredArgs(node) {
|
|
59
|
-
const destructuredArgs = []
|
|
60
|
-
node.params.forEach(
|
|
61
|
-
if (
|
|
62
|
-
param.
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
param.properties.forEach((prop) => {
|
|
67
|
-
const { name } = prop.value;
|
|
68
|
-
destructuredArgs.push(name);
|
|
69
|
-
});
|
|
63
|
+
const destructuredArgs = []
|
|
64
|
+
node.params.forEach(param => {
|
|
65
|
+
if (param.type === 'ObjectPattern' && param.properties && param.properties.length > 0) {
|
|
66
|
+
param.properties.forEach(prop => {
|
|
67
|
+
const { name } = prop.value
|
|
68
|
+
destructuredArgs.push(name)
|
|
69
|
+
})
|
|
70
70
|
}
|
|
71
|
-
})
|
|
71
|
+
})
|
|
72
72
|
|
|
73
|
-
return destructuredArgs
|
|
73
|
+
return destructuredArgs
|
|
74
74
|
}
|
package/lib/pause.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import colors from 'chalk'
|
|
2
|
+
import readline from 'readline'
|
|
3
|
+
import ora from 'ora-classic'
|
|
4
|
+
import debugModule from 'debug'
|
|
5
|
+
const debug = debugModule('codeceptjs:pause')
|
|
6
|
+
import container from './container.js'
|
|
7
|
+
import history from './history.js'
|
|
8
|
+
import store from './store.js'
|
|
9
|
+
import aiAssistant from './ai.js'
|
|
10
|
+
import recorder from './recorder.js'
|
|
11
|
+
import event from './event.js'
|
|
12
|
+
import output from './output.js'
|
|
13
|
+
import { methodsOfObject, searchWithFusejs } from './utils.js'
|
|
14
14
|
|
|
15
15
|
// npm install colors
|
|
16
16
|
let rl
|
|
@@ -234,6 +234,5 @@ function registerVariable(name, value) {
|
|
|
234
234
|
registeredVariables[name] = value
|
|
235
235
|
}
|
|
236
236
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
module.exports.registerVariable = registerVariable
|
|
237
|
+
export default pause
|
|
238
|
+
export { registerVariable }
|
package/lib/plugin/analyze.js
CHANGED
|
@@ -1,14 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const
|
|
1
|
+
import debugFactory from 'debug'
|
|
2
|
+
const debug = debugFactory('codeceptjs:analyze')
|
|
3
|
+
import { isMainThread } from 'node:worker_threads'
|
|
4
|
+
import figures from 'figures'
|
|
5
|
+
const { arrowRight } = figures
|
|
6
|
+
import Container from '../container.js'
|
|
7
|
+
// Container already imported correctly above
|
|
8
|
+
import store from '../store.js'
|
|
9
|
+
|
|
10
|
+
import aiModule from '../ai.js'
|
|
11
|
+
const ai = aiModule.default || aiModule
|
|
12
|
+
import colors from 'chalk'
|
|
13
|
+
import ora from 'ora'
|
|
14
|
+
import event from '../event.js'
|
|
15
|
+
|
|
16
|
+
import output from '../output.js'
|
|
17
|
+
|
|
18
|
+
import { ansiRegExp, base64EncodeFile, markdownToAnsi } from '../utils.js'
|
|
12
19
|
|
|
13
20
|
const MAX_DATA_LENGTH = 5000
|
|
14
21
|
|
|
@@ -212,7 +219,7 @@ const defaultConfig = {
|
|
|
212
219
|
* @param {Object} config - Plugin configuration
|
|
213
220
|
* @returns {void}
|
|
214
221
|
*/
|
|
215
|
-
|
|
222
|
+
export default function (config = {}) {
|
|
216
223
|
config = Object.assign(defaultConfig, config)
|
|
217
224
|
|
|
218
225
|
event.dispatcher.on(event.workers.before, () => {
|