-
Notifications
You must be signed in to change notification settings - Fork 62
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
feat: add ability to show user log in component tests #905
Conversation
47d7401
to
9d6e735
Compare
@@ -33,6 +34,8 @@ export class MochaWrapper { | |||
} | |||
|
|||
this._socket.emit(BrowserEventNames.initialize, getErrorsOnPageLoad(error)); | |||
|
|||
wrapConsoleMethods(); |
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.
Do it before run any runnable. I do not call it earlier so that all sorts of browser system logs are not displayed
socket.on(BrowserEventNames.callConsoleMethod, payload => { | ||
const { runUuid } = socket.handshake.auth; | ||
|
||
io.to(runUuid).except(socket.id).emit(BrowserEventNames.callConsoleMethod, payload); |
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.
I could call the console log right here (in master), but to my mind it's better to call it in the worker, that runs the test
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.
/ok
@@ -22,3 +22,5 @@ export const MAX_ARGS_LENGTH = 50; | |||
// used from - https://github.com/jestjs/jest/blob/726ca20752e38c18e20aa21740cec7aba7891946/packages/pretty-format/src/plugins/AsymmetricMatcher.ts#L11-L14 | |||
export const ASYMMETRIC_MATCHER = | |||
typeof Symbol === "function" && Symbol.for ? Symbol.for("jest.asymmetricMatcher") : 0x13_57_a5; | |||
|
|||
export const CONSOLE_METHODS = ["log", "info", "warn", "error", "debug"] as const; |
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.
What about trace
? Would it work?
table
also could be usefull.
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.
What about trace? Would it work?
It works, but stack trace is not quite helpful, because it called inside worker.
table also could be usefull.
Ok, I add it.
console[method] = (...args: unknown[]): void => { | ||
socket.emit(BrowserEventNames.callConsoleMethod, { method, args }); | ||
|
||
origCommand(...args); |
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.
nit: I suggest to use return origCommand(...args)
to preserve original API, just in case if sombody would overwrite console method too
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.
I have a synchronous event here. It means I can't return anything to browser. I don't see the point in such an implementation, since the real console
methods is still running in the browser. Here I just show arguments in terminal.
9d6e735
to
b1f1b7c
Compare
What is done
Added the ability to show user log in nodejs environment when tests run in browser environment