codeceptjs 4.0.1-beta.25 → 4.0.1-beta.27
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/bin/codecept.js +1 -2
- package/lib/command/{shell.js → interactive.js} +3 -31
- package/lib/config.js +3 -2
- package/lib/container.js +31 -3
- package/lib/helper/Playwright.js +186 -263
- package/lib/helper/Puppeteer.js +33 -115
- package/lib/helper/WebDriver.js +22 -114
- package/lib/helper/extras/PlaywrightLocator.js +34 -13
- package/lib/helper/extras/PlaywrightReactVueLocator.js +52 -0
- package/lib/locator.js +31 -117
- package/lib/mocha/test.js +4 -2
- package/lib/output.js +2 -2
- package/lib/step/record.js +9 -0
- package/lib/utils/typescript.js +61 -34
- package/package.json +8 -8
- package/typings/index.d.ts +1 -1
- package/typings/promiseBasedTypes.d.ts +5475 -3929
- package/typings/types.d.ts +5767 -4092
- package/lib/helper/errors/MultipleElementsFound.js +0 -135
package/bin/codecept.js
CHANGED
|
@@ -91,8 +91,7 @@ program
|
|
|
91
91
|
.option(commandFlags.profile.flag, commandFlags.profile.description)
|
|
92
92
|
.option(commandFlags.ai.flag, commandFlags.ai.description)
|
|
93
93
|
.option(commandFlags.config.flag, commandFlags.config.description)
|
|
94
|
-
.
|
|
95
|
-
.action(commandHandler('../lib/command/shell.js'))
|
|
94
|
+
.action(commandHandler('../lib/command/interactive.js'))
|
|
96
95
|
|
|
97
96
|
program.command('list [path]').alias('l').description('List all actions for I.').action(commandHandler('../lib/command/list.js'))
|
|
98
97
|
|
|
@@ -5,17 +5,9 @@ import Container from '../container.js'
|
|
|
5
5
|
import event from '../event.js'
|
|
6
6
|
import pause from '../pause.js'
|
|
7
7
|
import output from '../output.js'
|
|
8
|
-
import { fileURLToPath } from 'url'
|
|
9
|
-
import { createRequire } from 'module'
|
|
10
|
-
import path from 'path'
|
|
11
|
-
|
|
12
|
-
const require = createRequire(import.meta.url)
|
|
13
|
-
const __filename = fileURLToPath(import.meta.url)
|
|
14
|
-
const __dirname = path.dirname(__filename)
|
|
15
|
-
|
|
16
8
|
const webHelpers = Container.STANDARD_ACTING_HELPERS
|
|
17
9
|
|
|
18
|
-
export default async function (
|
|
10
|
+
export default async function (path, options) {
|
|
19
11
|
// Backward compatibility for --profile
|
|
20
12
|
process.profile = options.profile
|
|
21
13
|
process.env.profile = options.profile
|
|
@@ -25,7 +17,7 @@ export default async function (shellPath, options) {
|
|
|
25
17
|
const testsPath = getTestRoot(configFile)
|
|
26
18
|
|
|
27
19
|
const codecept = new Codecept(config, options)
|
|
28
|
-
|
|
20
|
+
codecept.init(testsPath)
|
|
29
21
|
|
|
30
22
|
try {
|
|
31
23
|
await codecept.bootstrap()
|
|
@@ -61,27 +53,7 @@ export default async function (shellPath, options) {
|
|
|
61
53
|
break
|
|
62
54
|
}
|
|
63
55
|
}
|
|
64
|
-
|
|
65
|
-
if (options.file) {
|
|
66
|
-
const scriptPath = path.resolve(options.file)
|
|
67
|
-
output.print(`Executing script: ${scriptPath}`)
|
|
68
|
-
|
|
69
|
-
// Use the same I actor that pause() uses
|
|
70
|
-
const I = Container.support('I')
|
|
71
|
-
global.I = I
|
|
72
|
-
globalThis.I = I
|
|
73
|
-
|
|
74
|
-
recorder.add('execute script', async () => {
|
|
75
|
-
try {
|
|
76
|
-
await import(scriptPath)
|
|
77
|
-
output.print('Script executed successfully')
|
|
78
|
-
} catch (err) {
|
|
79
|
-
output.error(`Error executing script: ${err.message}`)
|
|
80
|
-
}
|
|
81
|
-
})
|
|
82
|
-
} else {
|
|
83
|
-
pause()
|
|
84
|
-
}
|
|
56
|
+
pause()
|
|
85
57
|
recorder.add(() => event.emit(event.test.after, {}))
|
|
86
58
|
recorder.add(() => event.emit(event.suite.after, {}))
|
|
87
59
|
recorder.add(() => event.emit(event.all.result, {}))
|
package/lib/config.js
CHANGED
|
@@ -2,7 +2,7 @@ import fs from 'fs'
|
|
|
2
2
|
import path from 'path'
|
|
3
3
|
import { createRequire } from 'module'
|
|
4
4
|
import { fileExists, isFile, deepMerge, deepClone } from './utils.js'
|
|
5
|
-
import { transpileTypeScript, cleanupTempFiles } from './utils/typescript.js'
|
|
5
|
+
import { transpileTypeScript, cleanupTempFiles, fixErrorStack } from './utils/typescript.js'
|
|
6
6
|
|
|
7
7
|
const defaultConfig = {
|
|
8
8
|
output: './_output',
|
|
@@ -159,12 +159,13 @@ async function loadConfigFile(configFile) {
|
|
|
159
159
|
try {
|
|
160
160
|
// Use the TypeScript transpilation utility
|
|
161
161
|
const typescript = require('typescript')
|
|
162
|
-
const { tempFile, allTempFiles } = await transpileTypeScript(configFile, typescript)
|
|
162
|
+
const { tempFile, allTempFiles, fileMapping } = await transpileTypeScript(configFile, typescript)
|
|
163
163
|
|
|
164
164
|
try {
|
|
165
165
|
configModule = await import(tempFile)
|
|
166
166
|
cleanupTempFiles(allTempFiles)
|
|
167
167
|
} catch (err) {
|
|
168
|
+
fixErrorStack(err, fileMapping)
|
|
168
169
|
cleanupTempFiles(allTempFiles)
|
|
169
170
|
throw err
|
|
170
171
|
}
|
package/lib/container.js
CHANGED
|
@@ -5,7 +5,7 @@ import debugModule from 'debug'
|
|
|
5
5
|
const debug = debugModule('codeceptjs:container')
|
|
6
6
|
import { MetaStep } from './step.js'
|
|
7
7
|
import { methodsOfObject, fileExists, isFunction, isAsyncFunction, installedLocally, deepMerge } from './utils.js'
|
|
8
|
-
import { transpileTypeScript, cleanupTempFiles } from './utils/typescript.js'
|
|
8
|
+
import { transpileTypeScript, cleanupTempFiles, fixErrorStack } from './utils/typescript.js'
|
|
9
9
|
import Translation from './translation.js'
|
|
10
10
|
import MochaFactory from './mocha/factory.js'
|
|
11
11
|
import recorder from './recorder.js'
|
|
@@ -34,6 +34,7 @@ let container = {
|
|
|
34
34
|
/** @type {Result | null} */
|
|
35
35
|
result: null,
|
|
36
36
|
sharedKeys: new Set(), // Track keys shared via share() function
|
|
37
|
+
tsFileMapping: null, // TypeScript file mapping for error stack fixing
|
|
37
38
|
}
|
|
38
39
|
|
|
39
40
|
/**
|
|
@@ -176,6 +177,15 @@ class Container {
|
|
|
176
177
|
return container.translation
|
|
177
178
|
}
|
|
178
179
|
|
|
180
|
+
/**
|
|
181
|
+
* Get TypeScript file mapping for error stack fixing
|
|
182
|
+
*
|
|
183
|
+
* @api
|
|
184
|
+
*/
|
|
185
|
+
static tsFileMapping() {
|
|
186
|
+
return container.tsFileMapping
|
|
187
|
+
}
|
|
188
|
+
|
|
179
189
|
/**
|
|
180
190
|
* Get Mocha instance
|
|
181
191
|
*
|
|
@@ -401,18 +411,22 @@ async function requireHelperFromModule(helperName, config, HelperClass) {
|
|
|
401
411
|
// Handle TypeScript files
|
|
402
412
|
let importPath = moduleName
|
|
403
413
|
let tempJsFile = null
|
|
414
|
+
let fileMapping = null
|
|
404
415
|
const ext = path.extname(moduleName)
|
|
405
416
|
|
|
406
417
|
if (ext === '.ts') {
|
|
407
418
|
try {
|
|
408
419
|
// Use the TypeScript transpilation utility
|
|
409
420
|
const typescript = await import('typescript')
|
|
410
|
-
const { tempFile, allTempFiles } = await transpileTypeScript(importPath, typescript)
|
|
421
|
+
const { tempFile, allTempFiles, fileMapping: mapping } = await transpileTypeScript(importPath, typescript)
|
|
411
422
|
|
|
412
423
|
debug(`Transpiled TypeScript helper: ${importPath} -> ${tempFile}`)
|
|
413
424
|
|
|
414
425
|
importPath = tempFile
|
|
415
426
|
tempJsFile = allTempFiles
|
|
427
|
+
fileMapping = mapping
|
|
428
|
+
// Store file mapping in container for runtime error fixing
|
|
429
|
+
container.tsFileMapping = mapping
|
|
416
430
|
} catch (tsError) {
|
|
417
431
|
throw new Error(`Failed to load TypeScript helper ${importPath}: ${tsError.message}. Make sure 'typescript' package is installed.`)
|
|
418
432
|
}
|
|
@@ -433,6 +447,11 @@ async function requireHelperFromModule(helperName, config, HelperClass) {
|
|
|
433
447
|
cleanupTempFiles(filesToClean)
|
|
434
448
|
}
|
|
435
449
|
} catch (err) {
|
|
450
|
+
// Fix error stack to point to original .ts files
|
|
451
|
+
if (fileMapping) {
|
|
452
|
+
fixErrorStack(err, fileMapping)
|
|
453
|
+
}
|
|
454
|
+
|
|
436
455
|
// Clean up temp files before rethrowing
|
|
437
456
|
if (tempJsFile) {
|
|
438
457
|
const filesToClean = Array.isArray(tempJsFile) ? tempJsFile : [tempJsFile]
|
|
@@ -731,6 +750,7 @@ async function loadSupportObject(modulePath, supportObjectName) {
|
|
|
731
750
|
// Use dynamic import for both ESM and CJS modules
|
|
732
751
|
let importPath = modulePath
|
|
733
752
|
let tempJsFile = null
|
|
753
|
+
let fileMapping = null
|
|
734
754
|
|
|
735
755
|
if (typeof importPath === 'string') {
|
|
736
756
|
const ext = path.extname(importPath)
|
|
@@ -740,7 +760,7 @@ async function loadSupportObject(modulePath, supportObjectName) {
|
|
|
740
760
|
try {
|
|
741
761
|
// Use the TypeScript transpilation utility
|
|
742
762
|
const typescript = await import('typescript')
|
|
743
|
-
const { tempFile, allTempFiles } = await transpileTypeScript(importPath, typescript)
|
|
763
|
+
const { tempFile, allTempFiles, fileMapping: mapping } = await transpileTypeScript(importPath, typescript)
|
|
744
764
|
|
|
745
765
|
debug(`Transpiled TypeScript file: ${importPath} -> ${tempFile}`)
|
|
746
766
|
|
|
@@ -748,6 +768,9 @@ async function loadSupportObject(modulePath, supportObjectName) {
|
|
|
748
768
|
importPath = tempFile
|
|
749
769
|
// Store temp files list in a way that cleanup can access them
|
|
750
770
|
tempJsFile = allTempFiles
|
|
771
|
+
fileMapping = mapping
|
|
772
|
+
// Store file mapping in container for runtime error fixing
|
|
773
|
+
container.tsFileMapping = mapping
|
|
751
774
|
} catch (tsError) {
|
|
752
775
|
throw new Error(`Failed to load TypeScript file ${importPath}: ${tsError.message}. Make sure 'typescript' package is installed.`)
|
|
753
776
|
}
|
|
@@ -761,6 +784,11 @@ async function loadSupportObject(modulePath, supportObjectName) {
|
|
|
761
784
|
try {
|
|
762
785
|
obj = await import(importPath)
|
|
763
786
|
} catch (importError) {
|
|
787
|
+
// Fix error stack to point to original .ts files
|
|
788
|
+
if (fileMapping) {
|
|
789
|
+
fixErrorStack(importError, fileMapping)
|
|
790
|
+
}
|
|
791
|
+
|
|
764
792
|
// Clean up temp files if created before rethrowing
|
|
765
793
|
if (tempJsFile) {
|
|
766
794
|
const filesToClean = Array.isArray(tempJsFile) ? tempJsFile : [tempJsFile]
|