mirror of
https://gitlab.com/soapbox-pub/mkstack.git
synced 2025-08-27 04:59:22 +00:00
automatic console check via mkstack
This commit is contained in:
parent
a76c292fec
commit
00fa0eb30d
1667
package-lock.json
generated
1667
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -6,7 +6,8 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "npm i && vite",
|
"dev": "npm i && vite",
|
||||||
"build": "npm i && vite build && cp dist/index.html dist/404.html",
|
"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"
|
"deploy": "npm run build && npx -y nostr-deploy-cli deploy --skip-setup"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@ -83,6 +84,8 @@
|
|||||||
"globals": "^15.9.0",
|
"globals": "^15.9.0",
|
||||||
"jsdom": "^26.1.0",
|
"jsdom": "^26.1.0",
|
||||||
"postcss": "^8.4.47",
|
"postcss": "^8.4.47",
|
||||||
|
"puppeteer": "^24.14.0",
|
||||||
|
"serve": "^14.2.4",
|
||||||
"tailwindcss": "^3.4.11",
|
"tailwindcss": "^3.4.11",
|
||||||
"typescript": "^5.5.3",
|
"typescript": "^5.5.3",
|
||||||
"typescript-eslint": "^8.0.1",
|
"typescript-eslint": "^8.0.1",
|
||||||
|
75
src/test/console-check.js
Normal file
75
src/test/console-check.js
Normal 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);
|
||||||
|
});
|
Loading…
x
Reference in New Issue
Block a user