diff --git a/build.js b/build.js index 2b3096a..0390fa7 100755 --- a/build.js +++ b/build.js @@ -7,6 +7,7 @@ const tailwindcss = require('tailwindcss') const autoprefixer = require('autoprefixer') const isProduction = process.argv.includes('--production') +const isCI = process.env.CI === 'true' const watch = process.argv.includes('--watch') const copyChromeManifestPlugin = { @@ -69,6 +70,7 @@ const config = { define: { ISINSTOCK_URL: isProduction ? '"https://isinstock.com"' : '"http://localhost:3000"', CHROME_EXTENSION_ID: '"bnglflgcpflggbpbcbpgeaknekceeojd"', + CI: isCI ? 'true' : 'false', }, drop: isProduction ? ['console'] : [], loader: { diff --git a/src/@types/global.d.ts b/src/@types/global.d.ts index bbea4a2..5d7f91c 100644 --- a/src/@types/global.d.ts +++ b/src/@types/global.d.ts @@ -1,5 +1,6 @@ declare const ISINSTOCK_URL: string declare const CHROME_EXTENSION_ID: string +declare const CI: boolean declare module '*.css' { const content: string diff --git a/src/background.ts b/src/background.ts index ec23120..b597691 100644 --- a/src/background.ts +++ b/src/background.ts @@ -30,6 +30,11 @@ browser.tabs.onUpdated.addListener( ) browser.runtime.onStartup.addListener(async () => { + // onStartup cannot be tested with puppeteer so we skip it + if (CI) { + return + } + try { const token = await getBrowserExtensionInstallToken() if (token !== '') { @@ -46,6 +51,11 @@ browser.runtime.onStartup.addListener(async () => { // Register the install browser.runtime.onInstalled.addListener(async ({reason}) => { + // onInstalled cannot be tested with puppeteer so we skip it + if (CI) { + return + } + try { const existingToken = await getBrowserExtensionInstallToken() if (existingToken !== '') {