-
Notifications
You must be signed in to change notification settings - Fork 86
test: Reduce output noise #316
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
Changes from all commits
0b20e28
d29abc9
b585fc6
0674afb
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 |
|---|---|---|
|
|
@@ -8,7 +8,7 @@ describe( 'createCodeComponent', () => { | |
| const contextProps = { | ||
| blocks: [], | ||
| updateMessage: jest.fn(), | ||
| projectPath: '/path/to/project', | ||
| siteId: '1', | ||
|
Member
Author
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. This mirrors recent changes from #300. |
||
| messageId: 1, | ||
| }; | ||
| const CodeBlock = createCodeComponent( contextProps ); | ||
|
|
@@ -152,7 +152,7 @@ describe( 'createCodeComponent', () => { | |
| }, | ||
| ], | ||
| updateMessage: jest.fn(), | ||
| projectPath: '/path/to/project', | ||
| siteId: '1', | ||
| messageId: 1, | ||
| }; | ||
| const CodeBlock = createCodeComponent( contextProps ); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,7 +18,7 @@ describe( 'executeWPCli', () => { | |
| fs.writeFileSync( path.join( tmpPath, 'index.php' ), '' ); | ||
| } ); | ||
| afterAll( () => { | ||
| fs.rmdirSync( tmpPath, { recursive: true } ); | ||
|
Member
Author
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. Based on the observed log, this method is deprecated. |
||
| fs.rmSync( tmpPath, { recursive: true } ); | ||
| } ); | ||
|
|
||
| it( 'should execute wp-cli version command and return stdout and stderr', async () => { | ||
|
|
@@ -31,6 +31,10 @@ describe( 'executeWPCli', () => { | |
| } ); | ||
|
|
||
| it( 'should return error if wp-cli command does not exist', async () => { | ||
| const originalConsoleError = console.error; | ||
| const originalConsoleWarn = console.warn; | ||
| console.error = jest.fn(); | ||
| console.warn = jest.fn(); | ||
|
Comment on lines
+36
to
+37
Member
Author
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. As noted in the above test description, we expect an error to occur. Silencing it for test output reduces noise. |
||
| const args = [ 'yoda' ]; | ||
|
|
||
| const result = await executeWPCli( tmpPath, args ); | ||
|
|
@@ -39,6 +43,9 @@ describe( 'executeWPCli', () => { | |
| expect( result.stderr ).toContain( | ||
| "'yoda' is not a registered wp command. See 'wp help' for available commands." | ||
| ); | ||
|
|
||
| console.error = originalConsoleError; | ||
| console.warn = originalConsoleWarn; | ||
| } ); | ||
|
|
||
| it( 'should return the correct version of WP-CLI', async () => { | ||
|
|
||
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 consider this filtering approach to be a quick solution, but a more ideal solution would be a central logger utility that manages and formats logging in a consistent manner. This might allow us to disable logs in certain contexts (e.g., test runs via a
VERBOSE=falseenvironment variable) and ensure the same information (e.g., helpful metadata) is included for each log.