I've managed to do it, but it's not exactly easy...
Where the local extensions guru wOxxOm suggested preparing folder with "Preferences" file (thank you wOxxOm!).
This time, the flag "ack_ntp_bubble" is set in the "Secure Preferences" file.
So, what I did is to run the tests, approve the message, locate the current profile folder in the OS "Temp" folder, then copy the "Secure Preferences" file in a new folder - which will be used a template.
Then each time I run the tests, I'll copy this folder into the Temp folder and instruct Puppeteer to use this folder as profile.
In code it looks something like this:
const pathToExtension = path.join(process.cwd(), 'chrome_dev');
const templateProfilePath = 'C:\\tmp\\chrome_dev_profile';
const tempProfilePath = path.join(tmpdir(), `gsd_chrome_dev_profile_${Date.now()}`);
await cp(templateProfilePath, tempProfilePath, {recursive: true});
this.browser = await puppeteer.launch({
userDataDir: tempProfilePath, // this works, but it's persistent (also it changes the profile!)
headless: false,
devtools,
slowMo,
executablePath: 'C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe',
args: [
`--disable-extensions-except=${pathToExtension}`,
`--load-extension=${pathToExtension}`,
// `--user-data-dir=C:\\tmp\\chrome_dev_profile`,
],
});
this.browser.on('disconnected', async () => {
await timeoutPromise(1e3);
await rm(tempProfilePath, {recursive: true, force: true})
});
this.extPage = await this.browser.newPage();