codeceptjs 4.0.1-beta.23 → 4.0.1-beta.26

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 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
- .option('--file [path]', 'JavaScript file to execute in shell context')
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 (shellPath, options) {
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
- await codecept.init(testsPath)
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'
@@ -401,18 +401,20 @@ async function requireHelperFromModule(helperName, config, HelperClass) {
401
401
  // Handle TypeScript files
402
402
  let importPath = moduleName
403
403
  let tempJsFile = null
404
+ let fileMapping = null
404
405
  const ext = path.extname(moduleName)
405
406
 
406
407
  if (ext === '.ts') {
407
408
  try {
408
409
  // Use the TypeScript transpilation utility
409
410
  const typescript = await import('typescript')
410
- const { tempFile, allTempFiles } = await transpileTypeScript(importPath, typescript)
411
+ const { tempFile, allTempFiles, fileMapping: mapping } = await transpileTypeScript(importPath, typescript)
411
412
 
412
413
  debug(`Transpiled TypeScript helper: ${importPath} -> ${tempFile}`)
413
414
 
414
415
  importPath = tempFile
415
416
  tempJsFile = allTempFiles
417
+ fileMapping = mapping
416
418
  } catch (tsError) {
417
419
  throw new Error(`Failed to load TypeScript helper ${importPath}: ${tsError.message}. Make sure 'typescript' package is installed.`)
418
420
  }
@@ -433,6 +435,11 @@ async function requireHelperFromModule(helperName, config, HelperClass) {
433
435
  cleanupTempFiles(filesToClean)
434
436
  }
435
437
  } catch (err) {
438
+ // Fix error stack to point to original .ts files
439
+ if (fileMapping) {
440
+ fixErrorStack(err, fileMapping)
441
+ }
442
+
436
443
  // Clean up temp files before rethrowing
437
444
  if (tempJsFile) {
438
445
  const filesToClean = Array.isArray(tempJsFile) ? tempJsFile : [tempJsFile]
@@ -731,6 +738,7 @@ async function loadSupportObject(modulePath, supportObjectName) {
731
738
  // Use dynamic import for both ESM and CJS modules
732
739
  let importPath = modulePath
733
740
  let tempJsFile = null
741
+ let fileMapping = null
734
742
 
735
743
  if (typeof importPath === 'string') {
736
744
  const ext = path.extname(importPath)
@@ -740,7 +748,7 @@ async function loadSupportObject(modulePath, supportObjectName) {
740
748
  try {
741
749
  // Use the TypeScript transpilation utility
742
750
  const typescript = await import('typescript')
743
- const { tempFile, allTempFiles } = await transpileTypeScript(importPath, typescript)
751
+ const { tempFile, allTempFiles, fileMapping: mapping } = await transpileTypeScript(importPath, typescript)
744
752
 
745
753
  debug(`Transpiled TypeScript file: ${importPath} -> ${tempFile}`)
746
754
 
@@ -748,6 +756,7 @@ async function loadSupportObject(modulePath, supportObjectName) {
748
756
  importPath = tempFile
749
757
  // Store temp files list in a way that cleanup can access them
750
758
  tempJsFile = allTempFiles
759
+ fileMapping = mapping
751
760
  } catch (tsError) {
752
761
  throw new Error(`Failed to load TypeScript file ${importPath}: ${tsError.message}. Make sure 'typescript' package is installed.`)
753
762
  }
@@ -761,6 +770,11 @@ async function loadSupportObject(modulePath, supportObjectName) {
761
770
  try {
762
771
  obj = await import(importPath)
763
772
  } catch (importError) {
773
+ // Fix error stack to point to original .ts files
774
+ if (fileMapping) {
775
+ fixErrorStack(importError, fileMapping)
776
+ }
777
+
764
778
  // Clean up temp files if created before rethrowing
765
779
  if (tempJsFile) {
766
780
  const filesToClean = Array.isArray(tempJsFile) ? tempJsFile : [tempJsFile]