You're correct. If the stub is not provided for a standard module in the sfdx-lwc-jest repo, you'll need to create your own. Luckily, the lwc-recipes contains an example specifically for alert.
import { LightningElement, api } from 'lwc';
export default class Alert extends LightningElement {
static open() {
throw new Error(
'The LightningAlert documentation contains examples for mocking .open in Jest'
);
}
@api label;
@api message;
@api theme;
@api variant;
}
You'll also want to update your jest.config.js file which will point the import to your stub.
const { jestConfig } = require('@salesforce/sfdx-lwc-jest/config');
module.exports = {
...jestConfig,
moduleNameMapper: {
...
'^lightning/alert$':
'<rootDir>/force-app/test/jest-mocks/lightning/alert',
...
},
testTimeout: 10000
};
The above pattern is covered in Jest Test Patterns and Mock Dependencies under Module Imports