Skip to content

Commit 21cd4bb

Browse files
authored
Add more debug logging around code loading (#2389)
1 parent 7df2c9b commit 21cd4bb

File tree

7 files changed

+42
-47
lines changed

7 files changed

+42
-47
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
88
Please see [CONTRIBUTING.md](./CONTRIBUTING.md) on how to contribute to Cucumber.
99

1010
## [Unreleased]
11+
### Added
12+
- Add more debug logging around code loading ([#2389](https://github.com/cucumber/cucumber-js/pull/2389))
1113

1214
## [10.3.2] - 2024-03-27
1315
### Changed

package-lock.json

Lines changed: 13 additions & 37 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -209,14 +209,14 @@
209209
"node": "18 || 20 || 21"
210210
},
211211
"dependencies": {
212-
"@cucumber/ci-environment": "10.0.0",
213-
"@cucumber/cucumber-expressions": "17.0.1",
214-
"@cucumber/gherkin": "27.0.0",
212+
"@cucumber/ci-environment": "10.0.1",
213+
"@cucumber/cucumber-expressions": "17.1.0",
214+
"@cucumber/gherkin": "28.0.0",
215215
"@cucumber/gherkin-streams": "5.0.1",
216-
"@cucumber/gherkin-utils": "8.0.5",
217-
"@cucumber/html-formatter": "21.2.0",
216+
"@cucumber/gherkin-utils": "9.0.0",
217+
"@cucumber/html-formatter": "21.3.1",
218218
"@cucumber/message-streams": "4.0.1",
219-
"@cucumber/messages": "24.0.1",
219+
"@cucumber/messages": "24.1.0",
220220
"@cucumber/tag-expressions": "6.1.0",
221221
"assertion-error-formatter": "^3.0.0",
222222
"capital-case": "^1.0.4",
@@ -253,7 +253,7 @@
253253
},
254254
"devDependencies": {
255255
"@cucumber/compatibility-kit": "15.0.0",
256-
"@cucumber/query": "12.0.1",
256+
"@cucumber/query": "12.1.2",
257257
"@microsoft/api-extractor": "7.39.0",
258258
"@sinonjs/fake-timers": "10.0.2",
259259
"@types/chai": "4.3.4",

src/api/environment.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,13 @@ export function mergeEnvironment(
1818
},
1919
provided
2020
)
21+
const logger = new ConsoleLogger(
22+
fullEnvironment.stderr,
23+
fullEnvironment.debug
24+
)
25+
logger.debug('Resolved environment:', fullEnvironment)
2126
return {
2227
...fullEnvironment,
23-
logger: new ConsoleLogger(fullEnvironment.stderr, fullEnvironment.debug),
28+
logger: logger,
2429
}
2530
}

src/api/load_support.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export async function loadSupport(
3333
pluginManager.emit('paths:resolve', resolvedPaths)
3434
const { requirePaths, importPaths } = resolvedPaths
3535
const supportCodeLibrary = await getSupportCodeLibrary({
36+
logger,
3637
cwd,
3738
newId,
3839
requireModules: options.support.requireModules,

src/api/run_cucumber.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ export async function runCucumber(
5757
'originalCoordinates' in options.support
5858
? (options.support as SupportCodeLibrary)
5959
: await getSupportCodeLibrary({
60+
logger,
6061
cwd,
6162
newId,
6263
requirePaths,

src/api/support.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,17 @@ import { IdGenerator } from '@cucumber/messages'
33
import { SupportCodeLibrary } from '../support_code_library_builder/types'
44
import supportCodeLibraryBuilder from '../support_code_library_builder'
55
import tryRequire from '../try_require'
6+
import { ILogger } from '../logger'
67

78
export async function getSupportCodeLibrary({
9+
logger,
810
cwd,
911
newId,
1012
requireModules,
1113
requirePaths,
1214
importPaths,
1315
}: {
16+
logger: ILogger
1417
cwd: string
1518
newId: IdGenerator.NewId
1619
requireModules: string[]
@@ -23,10 +26,17 @@ export async function getSupportCodeLibrary({
2326
importPaths,
2427
})
2528

26-
requireModules.map((module) => tryRequire(module))
27-
requirePaths.map((path) => tryRequire(path))
29+
requireModules.map((path) => {
30+
logger.debug(`Attempting to require code from "${path}"`)
31+
tryRequire(path)
32+
})
33+
requirePaths.map((path) => {
34+
logger.debug(`Attempting to require code from "${path}"`)
35+
tryRequire(path)
36+
})
2837

2938
for (const path of importPaths) {
39+
logger.debug(`Attempting to import code from "${path}"`)
3040
await import(pathToFileURL(path).toString())
3141
}
3242

0 commit comments

Comments
 (0)