Only allow enablePrivateMethod to be true for lightning & interop namespaces#420
Merged
a-chabot merged 17 commits intosalesforce:masterfrom Apr 15, 2026
Merged
Conversation
Enable private methods support in LWC jest transformer by adding the enablePrivateMethods flag to compiler options. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Upgrade LWC packages from 9.0.3 to 9.1.0 for private methods support - Add integration tests for private methods feature - Tests verify that private methods work correctly within LWC components Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Replace Salesforce internal Nexus proxy URLs with public npm registry URLs to fix CI failures. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: a.chabot <a.chabot@salesforce.com>
Signed-off-by: a.chabot <a.chabot@salesforce.com>
Signed-off-by: a.chabot <a.chabot@salesforce.com>
Resolve jest-transformer index.js: keep conditional enablePrivateMethods (lightning/interop) instead of upstream always-true. Omit smoke/privateMethods fixture re-added upstream; lightning/privateMethods remains the integration target. Made-with: Cursor
Signed-off-by: a.chabot <a.chabot@salesforce.com>
Signed-off-by: a.chabot <a.chabot@salesforce.com>
Signed-off-by: a.chabot <a.chabot@salesforce.com>
wjhsf
reviewed
Apr 15, 2026
| describe('private methods', () => { | ||
| it('should allow calling private methods from public methods', () => { | ||
| const element = createElement('smoke-private-methods', { is: PrivateMethods }); | ||
| const element = createElement('lightning-private-methods', { is: PrivateMethods }); |
Contributor
There was a problem hiding this comment.
Can we test both smoke-private-methods and lightning-private-methods, since they'll behave differently?
Comment on lines
+7
to
+21
| jest.mock('@lwc/compiler/dist/index.cjs', () => ({ | ||
| transformSync: jest.fn(() => ({ | ||
| code: '/* lwc-compiled */', | ||
| map: null, | ||
| warnings: [], | ||
| })), | ||
| })); | ||
|
|
||
| jest.mock('@babel/core', () => ({ | ||
| transform: jest.fn(() => ({ code: '/* babel */' })), | ||
| })); | ||
|
|
||
| jest.mock('@lwc/template-compiler/dist/index.cjs', () => ({ | ||
| generateScopeTokens: jest.fn(() => ({ cssScopeTokens: undefined })), | ||
| })); |
Contributor
There was a problem hiding this comment.
Suggested change
| jest.mock('@lwc/compiler/dist/index.cjs', () => ({ | |
| transformSync: jest.fn(() => ({ | |
| code: '/* lwc-compiled */', | |
| map: null, | |
| warnings: [], | |
| })), | |
| })); | |
| jest.mock('@babel/core', () => ({ | |
| transform: jest.fn(() => ({ code: '/* babel */' })), | |
| })); | |
| jest.mock('@lwc/template-compiler/dist/index.cjs', () => ({ | |
| generateScopeTokens: jest.fn(() => ({ cssScopeTokens: undefined })), | |
| })); |
None of these are used in the string match helper.
|
|
||
| const { extractNamespace } = require('../index'); | ||
|
|
||
| describe('extractNamespace', () => { |
Contributor
There was a problem hiding this comment.
- Are the filepaths always absolute or do we need tests for relative?
- Add tests for
modules/x/foo/bar.jsandmodules/x/foo/bar/baz.js.
Signed-off-by: a.chabot <a.chabot@salesforce.com>
wjhsf
approved these changes
Apr 15, 2026
Signed-off-by: a.chabot <a.chabot@salesforce.com>
Signed-off-by: a.chabot <a.chabot@salesforce.com>
wjhsf
approved these changes
Apr 15, 2026
Comment on lines
+8
to
+14
| }).toThrow( | ||
| expect.objectContaining({ | ||
| message: expect.stringMatching( | ||
| /LWC1007:[\s\S]*Class private methods are not enabled/ | ||
| ), | ||
| }) | ||
| ); |
Contributor
There was a problem hiding this comment.
Suggested change
| }).toThrow( | |
| expect.objectContaining({ | |
| message: expect.stringMatching( | |
| /LWC1007:[\s\S]*Class private methods are not enabled/ | |
| ), | |
| }) | |
| ); | |
| }).toThrow(/LWC1007:[\s\S]*Class private methods are not enabled/); |
Suggested change
| }).toThrow( | |
| expect.objectContaining({ | |
| message: expect.stringMatching( | |
| /LWC1007:[\s\S]*Class private methods are not enabled/ | |
| ), | |
| }) | |
| ); | |
| }).toThrowError(/LWC1007:[\s\S]*Class private methods are not enabled/); |
One or the other is equivalent.
Collaborator
Author
There was a problem hiding this comment.
TypeError: expect(...).toThrowError is not a function
so I went with the toThrow option
Signed-off-by: a.chabot <a.chabot@salesforce.com>
Signed-off-by: a.chabot <a.chabot@salesforce.com>
Signed-off-by: a.chabot <a.chabot@salesforce.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.