1
0
mirror of https://github.com/hakimel/reveal.js.git synced 2025-08-09 08:06:48 +02:00

prettier config, format files

This commit is contained in:
Hakim El Hattab
2024-11-05 19:52:41 +01:00
parent 94a86f466d
commit faf8fb9c58
37 changed files with 1965 additions and 1836 deletions

108
test.js
View File

@@ -13,70 +13,70 @@ const combinedResults = { passed: 0, failed: 0, total: 0, runtime: 0 };
// Create and start Vite server
const startServer = async () => {
const server = await createServer({
root: __dirname,
server: {
port: 8009,
},
});
await server.listen();
return server;
const server = await createServer({
root: __dirname,
server: {
port: 8009,
},
});
await server.listen();
return server;
};
// Run tests
const runTests = async (server) => {
await Promise.all(
testFiles.map(async (file) => {
const qunitArgs = {
targetUrl: `http://localhost:8009/${file}`,
timeout: 30000,
redirectConsole: false,
puppeteerArgs: ['--allow-file-access-from-files'],
};
await Promise.all(
testFiles.map(async (file) => {
const qunitArgs = {
targetUrl: `http://localhost:8009/${file}`,
timeout: 30000,
redirectConsole: false,
puppeteerArgs: ['--allow-file-access-from-files'],
};
try {
const result = await runQunitPuppeteer(qunitArgs);
combinedResults.passed += result.stats.passed;
combinedResults.failed += result.stats.failed;
combinedResults.total += result.stats.total;
combinedResults.runtime += result.stats.runtime;
try {
const result = await runQunitPuppeteer(qunitArgs);
combinedResults.passed += result.stats.passed;
combinedResults.failed += result.stats.failed;
combinedResults.total += result.stats.total;
combinedResults.runtime += result.stats.runtime;
if (result.stats.failed > 0) {
console.log(
`${'!'} ${file} [${result.stats.passed}/${result.stats.total}] in ${
result.stats.runtime
}ms`.red
);
printFailedTests(result, console);
} else {
console.log(
`${'✔'} ${file} [${result.stats.passed}/${result.stats.total}] in ${
result.stats.runtime
}ms`.green
);
}
} catch (error) {
console.error(`Error running tests for ${file}:`, error);
}
})
);
if (result.stats.failed > 0) {
console.log(
`${'!'} ${file} [${result.stats.passed}/${result.stats.total}] in ${
result.stats.runtime
}ms`.red
);
printFailedTests(result, console);
} else {
console.log(
`${'✔'} ${file} [${result.stats.passed}/${result.stats.total}] in ${
result.stats.runtime
}ms`.green
);
}
} catch (error) {
console.error(`Error running tests for ${file}:`, error);
}
})
);
console.log(
`\n${combinedResults.passed}/${combinedResults.total} tests passed, ${combinedResults.failed} failed, ${combinedResults.runtime}ms runtime`
);
console.log(
`\n${combinedResults.passed}/${combinedResults.total} tests passed, ${combinedResults.failed} failed, ${combinedResults.runtime}ms runtime`
);
// Exit with status code 1 if any tests failed, otherwise exit with 0
process.exit(combinedResults.failed > 0 ? 1 : 0);
// Exit with status code 1 if any tests failed, otherwise exit with 0
process.exit(combinedResults.failed > 0 ? 1 : 0);
};
// Main execution
(async () => {
try {
const server = await startServer();
await runTests(server);
await server.close();
} catch (error) {
console.error('An error occurred:', error);
process.exit(1);
}
try {
const server = await startServer();
await runTests(server);
await server.close();
} catch (error) {
console.error('An error occurred:', error);
process.exit(1);
}
})();