netlify-plugin-expo-qr
Version:
Netlify Build Plugin to automate Expo app updates and generate QR code pages for Expo Go
58 lines (46 loc) โข 1.46 kB
JavaScript
// Simple test script to verify the plugin's QR code generation
const QRCode = require('qrcode');
const fs = require('fs');
const path = require('path');
async function testQRCodeGeneration() {
console.log('๐งช Testing QR code generation...');
try {
// Test URL
const testUrl = 'exp://exp.host/@username/project?release-channel=preview';
// Generate QR code
const qrCodeDataUri = await QRCode.toDataURL(testUrl, {
errorCorrectionLevel: 'M',
margin: 2,
width: 300
});
console.log('โ
QR code generated successfully');
console.log(`๐ฑ Data URI length: ${qrCodeDataUri.length} characters`);
// Create test HTML
const testHtml = `<!DOCTYPE html>
<html>
<head>
<title>Test QR Code</title>
</head>
<body>
<h1>Test QR Code</h1>
<img src="${qrCodeDataUri}" alt="Test QR Code" />
<p>URL: ${testUrl}</p>
</body>
</html>`;
// Write test file
const testDir = path.join(process.cwd(), 'test-output');
if (!fs.existsSync(testDir)) {
fs.mkdirSync(testDir, { recursive: true });
}
const testPath = path.join(testDir, 'test-qr.html');
fs.writeFileSync(testPath, testHtml);
console.log(`โ
Test HTML written to: ${testPath}`);
console.log('๐ All tests passed!');
} catch (error) {
console.error('โ Test failed:', error.message);
process.exit(1);
}
}
// Run test
testQRCodeGeneration();