Skip to content

test(e2e): add helper to assert no logs#5877

Merged
chenjiahan merged 1 commit intomainfrom
asset_no_logs_0818
Aug 18, 2025
Merged

test(e2e): add helper to assert no logs#5877
chenjiahan merged 1 commit intomainfrom
asset_no_logs_0818

Conversation

@chenjiahan
Copy link
Copy Markdown
Member

Summary

  • Replace manual log checks with expectLog and expectNoLog helper methods
  • Clean up test setup code by removing unnecessary file deletions
  • Rename createLogMatcher to createLogHelper for clarity

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

Copilot AI review requested due to automatic review settings August 18, 2025 13:29
@netlify
Copy link
Copy Markdown

netlify bot commented Aug 18, 2025

Deploy Preview for rsbuild ready!

Name Link
🔨 Latest commit 5ae6b4c
🔍 Latest deploy log https://app.netlify.com/projects/rsbuild/deploys/68a32aa21890ae000801a74f
😎 Deploy Preview https://deploy-preview-5877--rsbuild.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 83 (🟢 up 12 from production)
Accessibility: 97 (no change from production)
Best Practices: 100 (no change from production)
SEO: 100 (no change from production)
PWA: 60 (no change from production)
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

@chenjiahan chenjiahan merged commit 6ceaf0f into main Aug 18, 2025
12 checks passed
@chenjiahan chenjiahan deleted the asset_no_logs_0818 branch August 18, 2025 13:34
@chenjiahan chenjiahan changed the title test(test): add helper to assert no logs test(e2e): add helper to assert no logs Aug 18, 2025
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors logging test utilities by replacing manual log checks with standardized helper methods and cleaning up test setup code.

  • Renamed createLogMatcher to createLogHelper for better clarity
  • Added new expectNoLog helper method to complement existing expectLog functionality
  • Removed unnecessary file deletion operations in test setup code

Reviewed Changes

Copilot reviewed 21 out of 21 changed files in this pull request and generated 12 comments.

Show a summary per file
File Description
e2e/helper/logs.ts Added expectNoLog helper and renamed function/types for clarity
e2e/helper/jsApi.ts Updated variable names to use singular logHelper consistently
e2e/helper/cli.ts Simplified helper usage by spreading all methods from logHelper
e2e/cases/server/overlay/index.test.ts Updated import to use renamed createLogHelper
e2e/cases/server/overlay-type-errors/index.test.ts Updated import to use renamed createLogHelper
e2e/cases/rsdoctor/index.test.ts Replaced manual log checks with expectLog/expectNoLog helpers
e2e/cases/print-file-size/with-error/index.test.ts Replaced manual log check with expectNoLog helper
e2e/cases/lazy-compilation/port-placeholder/index.test.ts Replaced manual log check with expectNoLog helper
e2e/cases/lazy-compilation/dynamic-import/index.test.ts Replaced manual log check with expectNoLog helper and removed unused import
e2e/cases/lazy-compilation/basic/index.test.ts Replaced manual log checks with expectNoLog helper
e2e/cases/css/import-common-css/index.test.ts Removed manual log check code
e2e/cases/css/enable-experiments-css/index.test.ts Replaced manual log checks with expectNoLog helper
e2e/cases/config/stats-options/index.test.ts Replaced manual log checks with expectLog/expectNoLog helpers
e2e/cases/config/inspect-config/index.test.ts Replaced manual log checks with expectLog helper
e2e/cases/config/debug-mode/index.test.ts Replaced manual log checks with expectLog helper
e2e/cases/cli/watch-files/index.test.ts Removed unnecessary file deletion in test setup
e2e/cases/cli/watch-files-array/index.test.ts Removed unnecessary file deletion in test setup
e2e/cases/cli/reload-env/index.test.ts Removed file deletions and added proper async log expectations
e2e/cases/cli/build-watch/index.test.ts Removed unnecessary file deletions in test setup
e2e/cases/cli/build-watch-restart/index.test.ts Improved test flow with proper async expectations and removed file deletions
e2e/cases/cli/build-watch-options/index.test.ts Replaced manual log check with expectNoLog helper

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

});
};

const expectNoLog = (pattern: LogPattern) => {
Copy link

Copilot AI Aug 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The expectNoLog function returns a boolean synchronously, which is inconsistent with expectLog that returns a Promise. This could cause issues when used with await statements in test files. Consider making this function async or removing the return statement to match the pattern of other expectation functions.

Suggested change
const expectNoLog = (pattern: LogPattern) => {
const expectNoLog = async (pattern: LogPattern) => {

Copilot uses AI. Check for mistakes.
expect(
logs.some((log) => log.includes('@rsdoctor') && log.includes('enabled')),
).toBe(false);
expectNoLog(RSDOCTOR_LOG);
Copy link

Copilot AI Aug 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The expectNoLog call is missing await. Since this function is used in an async context and other expectLog calls are awaited, this should also be awaited for consistency and proper test execution flow.

Suggested change
expectNoLog(RSDOCTOR_LOG);
await expectNoLog(RSDOCTOR_LOG);

Copilot uses AI. Check for mistakes.
expect(
logs.some((log) => log.includes('@rsdoctor') && log.includes('enabled')),
).toBe(false);
expectNoLog(RSDOCTOR_LOG);
Copy link

Copilot AI Aug 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The expectNoLog call is missing await. Since this function is used in an async context and other expectLog calls are awaited, this should also be awaited for consistency and proper test execution flow.

Suggested change
expectNoLog(RSDOCTOR_LOG);
await expectNoLog(RSDOCTOR_LOG);

Copilot uses AI. Check for mistakes.

expect(rsbuild.buildError).toBeTruthy();
expect(rsbuild.logs.some((log) => log.includes('Total:'))).toBeFalsy();
rsbuild.expectNoLog('Total:');
Copy link

Copilot AI Aug 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The expectNoLog call is missing await. Since this is used in an async test context, it should be awaited for proper test execution.

Suggested change
rsbuild.expectNoLog('Total:');
await rsbuild.expectNoLog('Total:');

Copilot uses AI. Check for mistakes.
expect(
rsbuild.logs.some((log) => log.includes('building src/page2/index.js')),
).toBeFalsy();
rsbuild.expectNoLog('building src/page2/index.js');
Copy link

Copilot AI Aug 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The expectNoLog call is missing await. Since this is used in an async test context and other expectLog calls are awaited, this should also be awaited for consistency.

Suggested change
rsbuild.expectNoLog('building src/page2/index.js');
await rsbuild.expectNoLog('building src/page2/index.js');

Copilot uses AI. Check for mistakes.
expect(
rsbuild.logs.some((log) => log.includes('building src/page2/index.js')),
).toBeFalsy();
rsbuild.expectNoLog('building src/page2/index.js');
Copy link

Copilot AI Aug 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The expectNoLog call is missing await. Since this is used in an async test context and other expectLog calls are awaited, this should also be awaited for consistency.

Suggested change
rsbuild.expectNoLog('building src/page2/index.js');
await rsbuild.expectNoLog('building src/page2/index.js');

Copilot uses AI. Check for mistakes.
expect(
rsbuild.logs.some((log) => log.includes('Compile Warning')),
).toBeFalsy();
rsbuild.expectNoLog(COMPILE_WARNING);
Copy link

Copilot AI Aug 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The expectNoLog call is missing await. Since this is used in an async test context, it should be awaited for proper test execution.

Suggested change
rsbuild.expectNoLog(COMPILE_WARNING);
await rsbuild.expectNoLog(COMPILE_WARNING);

Copilot uses AI. Check for mistakes.
expect(
rsbuild.logs.some((log) => log.includes('Compile Warning')),
).toBeFalsy();
rsbuild.expectNoLog(COMPILE_WARNING);
Copy link

Copilot AI Aug 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The expectNoLog call is missing await. Since this is used in an async test context, it should be awaited for proper test execution.

Suggested change
rsbuild.expectNoLog(COMPILE_WARNING);
await rsbuild.expectNoLog(COMPILE_WARNING);

Copilot uses AI. Check for mistakes.
),
).toBeFalsy();

rsbuild.expectNoLog(WARNING_MSG);
Copy link

Copilot AI Aug 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The expectNoLog call is missing await. Since this is used in an async test context and other expectLog calls are awaited, this should also be awaited for consistency.

Suggested change
rsbuild.expectNoLog(WARNING_MSG);
await rsbuild.expectNoLog(WARNING_MSG);

Copilot uses AI. Check for mistakes.
expect(
logs.some((log) => /building test-temp-src[\\/]bar.js/.test(log)),
).toBeFalsy();
expectNoLog(/building test-temp-src[\\/]bar.js/);
Copy link

Copilot AI Aug 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The expectNoLog call is missing await. Since this is used in an async test context and other expectLog calls are awaited, this should also be awaited for consistency.

Suggested change
expectNoLog(/building test-temp-src[\\/]bar.js/);
await expectNoLog(/building test-temp-src[\\/]bar.js/);

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants