Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more debug logging around code loading #2389

Merged
merged 4 commits into from
Apr 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
Please see [CONTRIBUTING.md](./CONTRIBUTING.md) on how to contribute to Cucumber.

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

## [10.3.2] - 2024-03-27
### Changed
Expand Down
50 changes: 13 additions & 37 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -209,14 +209,14 @@
"node": "18 || 20 || 21"
},
"dependencies": {
"@cucumber/ci-environment": "10.0.0",
"@cucumber/cucumber-expressions": "17.0.1",
"@cucumber/gherkin": "27.0.0",
"@cucumber/ci-environment": "10.0.1",
"@cucumber/cucumber-expressions": "17.1.0",
"@cucumber/gherkin": "28.0.0",
"@cucumber/gherkin-streams": "5.0.1",
"@cucumber/gherkin-utils": "8.0.5",
"@cucumber/html-formatter": "21.2.0",
"@cucumber/gherkin-utils": "9.0.0",
"@cucumber/html-formatter": "21.3.1",
"@cucumber/message-streams": "4.0.1",
"@cucumber/messages": "24.0.1",
"@cucumber/messages": "24.1.0",
"@cucumber/tag-expressions": "6.1.0",
"assertion-error-formatter": "^3.0.0",
"capital-case": "^1.0.4",
Expand Down Expand Up @@ -253,7 +253,7 @@
},
"devDependencies": {
"@cucumber/compatibility-kit": "15.0.0",
"@cucumber/query": "12.0.1",
"@cucumber/query": "12.1.2",
"@microsoft/api-extractor": "7.39.0",
"@sinonjs/fake-timers": "10.0.2",
"@types/chai": "4.3.4",
Expand Down
7 changes: 6 additions & 1 deletion src/api/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,13 @@ export function mergeEnvironment(
},
provided
)
const logger = new ConsoleLogger(
fullEnvironment.stderr,
fullEnvironment.debug
)
logger.debug('Resolved environment:', fullEnvironment)
return {
...fullEnvironment,
logger: new ConsoleLogger(fullEnvironment.stderr, fullEnvironment.debug),
logger: logger,
}
}
1 change: 1 addition & 0 deletions src/api/load_support.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export async function loadSupport(
pluginManager.emit('paths:resolve', resolvedPaths)
const { requirePaths, importPaths } = resolvedPaths
const supportCodeLibrary = await getSupportCodeLibrary({
logger,
cwd,
newId,
requireModules: options.support.requireModules,
Expand Down
1 change: 1 addition & 0 deletions src/api/run_cucumber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export async function runCucumber(
'originalCoordinates' in options.support
? (options.support as SupportCodeLibrary)
: await getSupportCodeLibrary({
logger,
cwd,
newId,
requirePaths,
Expand Down
14 changes: 12 additions & 2 deletions src/api/support.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@ import { IdGenerator } from '@cucumber/messages'
import { SupportCodeLibrary } from '../support_code_library_builder/types'
import supportCodeLibraryBuilder from '../support_code_library_builder'
import tryRequire from '../try_require'
import { ILogger } from '../logger'

export async function getSupportCodeLibrary({
logger,
cwd,
newId,
requireModules,
requirePaths,
importPaths,
}: {
logger: ILogger
cwd: string
newId: IdGenerator.NewId
requireModules: string[]
Expand All @@ -23,10 +26,17 @@ export async function getSupportCodeLibrary({
importPaths,
})

requireModules.map((module) => tryRequire(module))
requirePaths.map((path) => tryRequire(path))
requireModules.map((path) => {
logger.debug(`Attempting to require code from "${path}"`)
tryRequire(path)
})
requirePaths.map((path) => {
logger.debug(`Attempting to require code from "${path}"`)
tryRequire(path)
})

for (const path of importPaths) {
logger.debug(`Attempting to import code from "${path}"`)
await import(pathToFileURL(path).toString())
}

Expand Down
Loading