@@ -47,20 +47,36 @@ function resolveAsFile(name, extensions) {
4747 return undefined ;
4848}
4949
50- function getLightningMock ( modulePath ) {
51- const p = path . join ( __dirname , 'lightning-stubs' , modulePath ) ;
50+ function getModuleMock ( modulePath , moduleName ) {
51+ const p = path . join ( __dirname , modulePath , moduleName ) ;
5252 if ( fs . existsSync ( p ) ) {
53- return path . join ( p , modulePath + '.js' ) ;
53+ return path . join ( p , moduleName + '.js' ) ;
5454 }
5555}
5656
57+ function getLightningMock ( moduleName ) {
58+ return getModuleMock ( 'lightning-stubs' , moduleName ) ;
59+ }
60+
61+ function getApexMock ( moduleName ) {
62+ return getModuleMock ( 'apex-stubs' , moduleName ) ;
63+ }
64+
5765function getModule ( modulePath , options ) {
5866 const { ns, name } = getInfoFromId ( modulePath ) ;
5967
6068 if ( ns === 'lightning' ) {
6169 return getLightningMock ( name ) ;
6270 }
6371
72+ // See https://developer.salesforce.com/docs/component-library/documentation/en/lwc/reference_salesforce_modules
73+ if (
74+ modulePath . startsWith ( '@salesforce/apex/' ) ||
75+ modulePath . startsWith ( '@salesforce/apexContinuation/' )
76+ ) {
77+ return getApexMock ( 'method' ) ;
78+ }
79+
6480 if ( ns === DEFAULT_NAMESPACE ) {
6581 const paths = getModulePaths ( ) ;
6682 for ( let i = 0 ; i < paths . length ; i ++ ) {
0 commit comments