Skip to content

Conversation

@jongpie
Copy link
Owner

@jongpie jongpie commented Jul 22, 2025

Fixed #870 by updating the logger LWC initialization message to only print when JavaScript console logging is enabled via LoggerSettings__c. Also resolved some test isolation issues in logger.test.js + test improvements + code cleanup

  • Updated loggerService.js to only call console.info() with an init message ('logger component initialized') when console logging is enabled via LoggerSettings__c.IsJavaScriptConsoleLoggingEnabled__c
  • Replaced enableSystemMessages() and disableSystemMessages() in loggerService.js with a new static variable LoggerService.areSystemMessagesEnabled (intended for internal-use only)
  • Updated logger.test.js to reset LoggerService.hasInitialized and LoggerService.areSystemMessagesEnabled static variables in beforeEach() (instead of afterAll())
  • Switched to using jest.resetAllMocks() instead of jest.clearAllMocks() in logger.test.js for better test isolation
  • Updated all test functions to consistently use all 3 logger creation methods (createLogger, getLogger, and getMarkupLogger)

Also include a 🤏 liiiiiiitle bit of scope creep:

  • Updated all Jest tests to import createElement from '@lwc/engine-dom' (instead of 'lwc')
  • Updated the project's threshold for code coverage in codecov.yml to compensate for the lower code coverage in LWC tests for now (currently around ~86%). Eventually, tests & code coverage for LWC will be improved - but for now, the constant pipeline alerts from codecov.io aren't particularly helpful 😅
  • Cleaned up a small code block in LogBatchPurger using the null coalescing operator (??) to reduce the lines of code needed
  • Corrected the label on field LoggerScenarioRule__mdt.IsLogAssignmentEnabled__c to use the term Logger Scenario, instead of the deprecated term Log Scenario

jongpie added 3 commits July 21, 2025 16:19
…sage of 'logger component initialized' when console logging is enabled via LoggerSettings__c.IsJavaScriptConsoleLoggingEnabled__c
…eed for enableSystemMessages() and disableSystemMessages() functions in loggerService.js

- Replaced enableSystemMessages() and disableSystemMessages() with new static variable LoggerService.areSystemMessagesEnabled
- Switched to using jest.resetAllMocks() instead of jest.clearAllMocks() for better test isolation
- Updated tests to reset LoggerService.hasInitialized and LoggerService.areSystemMessagesEnabled static variables in beforeEach() instead of afterAll()
- Updated all test functions to consistently use all logger creation methods (createLogger, getLogger, getMarkupLogger)
@jongpie jongpie added Type: Bug Something isn't working Layer: Configuration Items related to the custom hierarchy setting LoggerSettings__c or any included custom metadata type Logging Source: Lightning Components Items related to using Nebula Logger using JavaScript within lightning components (lwc & aura) Layer: Logger Engine Items related to the core logging engine tests Relates to Apex or LWC jest tests labels Jul 22, 2025
@jongpie jongpie temporarily deployed to Event Monitoring Scratch Org July 22, 2025 02:04 — with GitHub Actions Inactive
@jongpie jongpie had a problem deploying to Advanced Scratch Org July 22, 2025 02:04 — with GitHub Actions Error
@jongpie jongpie had a problem deploying to Platform Cache Scratch Org July 22, 2025 02:15 — with GitHub Actions Error
@jongpie jongpie temporarily deployed to Advanced Scratch Org July 22, 2025 02:19 — with GitHub Actions Inactive
@jongpie jongpie had a problem deploying to Event Monitoring Scratch Org July 22, 2025 02:19 — with GitHub Actions Failure
@jongpie jongpie temporarily deployed to Base Scratch Org July 22, 2025 02:19 — with GitHub Actions Inactive
@jongpie jongpie temporarily deployed to OmniStudio Scratch Org July 22, 2025 02:29 — with GitHub Actions Inactive
@jongpie jongpie temporarily deployed to Experience Cloud Scratch Org July 22, 2025 02:36 — with GitHub Actions Inactive
@jongpie jongpie temporarily deployed to Event Monitoring Scratch Org July 22, 2025 03:13 — with GitHub Actions Inactive
@jongpie jongpie temporarily deployed to Platform Cache Scratch Org July 22, 2025 03:25 — with GitHub Actions Inactive
@jongpie jongpie temporarily deployed to Base Scratch Org July 22, 2025 03:41 — with GitHub Actions Inactive
@jongpie jongpie temporarily deployed to Base Scratch Org July 22, 2025 03:52 — with GitHub Actions Inactive
@jongpie jongpie force-pushed the bugfix/skip-lwc-init-message branch from 04155b3 to f3339bc Compare July 22, 2025 04:20
@jongpie jongpie had a problem deploying to Event Monitoring Scratch Org July 22, 2025 04:22 — with GitHub Actions Error
@jongpie jongpie had a problem deploying to Advanced Scratch Org July 22, 2025 04:22 — with GitHub Actions Error
…nsate for the lower code coverage in LWC tests for now

Eventually, code coverage for LWC will be increased - but for now, the constant alerts from codecov.io aren't particularly helpful ^_^
@jongpie jongpie force-pushed the bugfix/skip-lwc-init-message branch from f3339bc to d19ee0b Compare July 22, 2025 04:23
@jongpie jongpie had a problem deploying to Advanced Scratch Org July 22, 2025 04:24 — with GitHub Actions Failure
@jongpie jongpie had a problem deploying to Event Monitoring Scratch Org July 22, 2025 04:24 — with GitHub Actions Failure
@jongpie jongpie had a problem deploying to Base Scratch Org July 22, 2025 04:24 — with GitHub Actions Failure
@jongpie jongpie temporarily deployed to Advanced Scratch Org July 22, 2025 04:28 — with GitHub Actions Inactive
@jongpie jongpie temporarily deployed to Event Monitoring Scratch Org July 22, 2025 04:28 — with GitHub Actions Inactive
@jongpie jongpie temporarily deployed to Base Scratch Org July 22, 2025 04:28 — with GitHub Actions Inactive
@jongpie jongpie temporarily deployed to Platform Cache Scratch Org July 22, 2025 04:39 — with GitHub Actions Inactive
@jongpie jongpie temporarily deployed to OmniStudio Scratch Org July 22, 2025 04:40 — with GitHub Actions Inactive
@jongpie jongpie temporarily deployed to Experience Cloud Scratch Org July 22, 2025 04:44 — with GitHub Actions Inactive
@jongpie jongpie temporarily deployed to Base Scratch Org July 22, 2025 04:59 — with GitHub Actions Inactive
@jongpie jongpie temporarily deployed to Base Scratch Org July 22, 2025 05:10 — with GitHub Actions Inactive
Comment on lines 3 to 4
import { BrowserContext } from '../loggerService';
import LoggerService from '../loggerService';
Copy link
Owner Author

Choose a reason for hiding this comment

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

@jamessimone random readability/style-preference question for you - for imports like this (with a default + named exports), do you go for a one-liner? Or do you like to keep them separated?

Suggested change
import { BrowserContext } from '../loggerService';
import LoggerService from '../loggerService';
import LoggerService, { BrowserContext } from '../loggerService';

@jongpie jongpie force-pushed the bugfix/skip-lwc-init-message branch from 8624df3 to 3296b6b Compare July 23, 2025 03:05
@jongpie jongpie temporarily deployed to Event Monitoring Scratch Org July 23, 2025 03:06 — with GitHub Actions Inactive
@jongpie jongpie temporarily deployed to Advanced Scratch Org July 23, 2025 03:06 — with GitHub Actions Inactive
@jongpie jongpie had a problem deploying to Base Scratch Org July 23, 2025 03:06 — with GitHub Actions Failure
@jongpie jongpie temporarily deployed to Platform Cache Scratch Org July 23, 2025 03:19 — with GitHub Actions Inactive
@jongpie jongpie temporarily deployed to Experience Cloud Scratch Org July 23, 2025 03:25 — with GitHub Actions Inactive
@jongpie jongpie temporarily deployed to Base Scratch Org July 23, 2025 03:54 — with GitHub Actions Inactive
@jongpie jongpie temporarily deployed to OmniStudio Scratch Org July 23, 2025 04:07 — with GitHub Actions Inactive
@jongpie jongpie temporarily deployed to Base Scratch Org July 23, 2025 04:22 — with GitHub Actions Inactive
@jongpie jongpie temporarily deployed to Base Scratch Org July 23, 2025 04:32 — with GitHub Actions Inactive
@codecov
Copy link

codecov bot commented Jul 23, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.50%. Comparing base (b34b2c0) to head (3296b6b).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #884      +/-   ##
==========================================
+ Coverage   86.19%   91.50%   +5.31%     
==========================================
  Files          17       58      +41     
  Lines        1318     6312    +4994     
  Branches      199      199              
==========================================
+ Hits         1136     5776    +4640     
- Misses        162      516     +354     
  Partials       20       20              
Flag Coverage Δ
Apex 92.91% <100.00%> (?)
LWC 86.13% <100.00%> (-0.06%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jongpie jongpie merged commit 2ab4af9 into main Jul 23, 2025
1 check passed
@jongpie jongpie deleted the bugfix/skip-lwc-init-message branch July 23, 2025 22:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Layer: Configuration Items related to the custom hierarchy setting LoggerSettings__c or any included custom metadata type Layer: Logger Engine Items related to the core logging engine Logging Source: Lightning Components Items related to using Nebula Logger using JavaScript within lightning components (lwc & aura) tests Relates to Apex or LWC jest tests Type: Bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Disabling system messages in LWC component

3 participants