automatic console check via mkstack

This commit is contained in:
Chad Curtis 2025-07-16 18:38:04 +00:00
parent a76c292fec
commit 00fa0eb30d
3 changed files with 1739 additions and 8 deletions

1667
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -6,7 +6,8 @@
"scripts": {
"dev": "npm i && vite",
"build": "npm i && vite build && cp dist/index.html dist/404.html",
"test": "npm i && tsc -p tsconfig.app.json --noEmit && eslint && vitest run && vite build",
"test": "npm i && tsc -p tsconfig.app.json --noEmit && eslint && vitest run && npm run test:console",
"test:console": "node src/test/console-check.js",
"deploy": "npm run build && npx -y nostr-deploy-cli deploy --skip-setup"
},
"dependencies": {
@ -83,6 +84,8 @@
"globals": "^15.9.0",
"jsdom": "^26.1.0",
"postcss": "^8.4.47",
"puppeteer": "^24.14.0",
"serve": "^14.2.4",
"tailwindcss": "^3.4.11",
"typescript": "^5.5.3",
"typescript-eslint": "^8.0.1",

75
src/test/console-check.js Normal file
View File

@ -0,0 +1,75 @@
#!/usr/bin/env node
import puppeteer from 'puppeteer';
const SITE_URL = process.env.DEPLOY_URL;
if (!SITE_URL) {
console.error('❌ DEPLOY_URL environment variable is required');
process.exit(1);
}
async function checkConsole() {
console.log(`🔍 Checking ${SITE_URL} for console errors...`);
const browser = await puppeteer.launch({ headless: true });
try {
const page = await browser.newPage();
const errors = [];
const warnings = [];
page.on('console', (msg) => {
const text = msg.text();
const type = msg.type();
if (type === 'error') {
errors.push(text);
} else if (type === 'warn') {
warnings.push(text);
}
});
page.on('pageerror', (error) => {
errors.push(`Page error: ${error.message}`);
});
await page.goto(SITE_URL, {
waitUntil: 'networkidle0',
timeout: 15000
});
// Allow time for any async errors
await new Promise(resolve => setTimeout(resolve, 1000));
// Filter out common non-critical issues
const filteredErrors = errors.filter(error =>
!error.includes('404') &&
!error.includes('manifest.webmanifest') &&
!error.includes('favicon.ico') &&
!error.includes('net::ERR_ABORTED')
);
if (filteredErrors.length > 0) {
console.error('❌ Console errors found:');
filteredErrors.forEach(err => console.error(` - ${err}`));
process.exit(1);
}
if (warnings.length > 0) {
console.warn('⚠️ Console warnings (non-blocking):');
warnings.forEach(warn => console.warn(` - ${warn}`));
}
console.log('✅ No critical console errors found!');
} finally {
await browser.close();
}
}
checkConsole().catch(error => {
console.error('❌ Console check failed:', error.message);
process.exit(1);
});