-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
fix: Extend mock logger used in angular bootstrap #25500
Changes from 1 commit
491ba37
9873fa4
6a3c33b
3c62db1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,8 +6,10 @@ import type { PresetHandlerResult, WebpackDevServerConfig } from '../devServer' | |
import { dynamicAbsoluteImport, dynamicImport } from '../dynamic-import' | ||
import { sourceDefaultWebpackDependencies } from './sourceRelativeWebpackModules' | ||
import debugLib from 'debug' | ||
import type { logging } from '@angular-devkit/core' | ||
|
||
const debug = debugLib('cypress:webpack-dev-server:angularHandler') | ||
const debugPrefix = 'cypress:webpack-dev-server:angularHandler' | ||
const debug = debugLib(debugPrefix) | ||
|
||
export type BuildOptions = Record<string, any> | ||
|
||
|
@@ -203,14 +205,23 @@ export async function getAngularJson (projectRoot: string): Promise<AngularJson> | |
return JSON.parse(angularJson) | ||
} | ||
|
||
function buildLogger (name: string = ''): logging.Logger { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems this is only called once (below) and There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's actually called in two places, one of which is within itself so it's easy to miss. We call it once with no name for the root logger, and the |
||
const debugLogger = debugLib(`${debugPrefix}${name ? `:${name}` : ''}`) | ||
|
||
return { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cannot find any docs in Angular about the logger, nice job figuring this out. Another option if we want to cover all bases might be using a Will let you make the final call, just throwing another suggestion out there. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Took another look based on your suggestion and I ended up finding a better alternative - just build an actual |
||
name, | ||
log: debugLogger, | ||
debug: debugLogger, | ||
info: debugLogger, | ||
warn: debugLogger, | ||
error: debugLogger, | ||
fatal: debugLogger, | ||
createChild: buildLogger, | ||
} as unknown as logging.Logger | ||
} | ||
|
||
function createFakeContext (projectRoot: string, defaultProjectConfig: Cypress.AngularDevServerProjectConfig) { | ||
const logger = { | ||
createChild: () => { | ||
return { | ||
warn: () => {}, | ||
} | ||
}, | ||
} | ||
const logger: logging.LoggerApi = buildLogger() | ||
|
||
const context = { | ||
target: { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not your change but woah,60000, does the spec really take that long to execute? 🐢
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The angular tests especially (and other frameworks to a lesser extent) take forever to bundle & launch webpack on Windows, so I think this was added to work around that.