mirror of
https://github.com/hakimel/reveal.js.git
synced 2025-08-20 21:41:25 +02:00
run qunit test suite without gulp
This commit is contained in:
@@ -47,7 +47,7 @@
|
|||||||
"dev": "vite --port 8000",
|
"dev": "vite --port 8000",
|
||||||
"build:core": "tsc && vite build && vite build -c vite.config.styles.ts",
|
"build:core": "tsc && vite build && vite build -c vite.config.styles.ts",
|
||||||
"build": "tsc && vite build && vite build -c vite.config.styles.ts && vite build -c plugin/highlight/vite.config.ts && vite build -c plugin/markdown/vite.config.ts && vite build -c plugin/math/vite.config.ts && vite build -c plugin/notes/vite.config.ts && vite build -c plugin/search/vite.config.ts && vite build -c plugin/zoom/vite.config.ts",
|
"build": "tsc && vite build && vite build -c vite.config.styles.ts && vite build -c plugin/highlight/vite.config.ts && vite build -c plugin/markdown/vite.config.ts && vite build -c plugin/math/vite.config.ts && vite build -c plugin/notes/vite.config.ts && vite build -c plugin/search/vite.config.ts && vite build -c plugin/zoom/vite.config.ts",
|
||||||
"test": "gulp test",
|
"test": "node test.cjs",
|
||||||
"start": "vite --port 8000"
|
"start": "vite --port 8000"
|
||||||
},
|
},
|
||||||
"author": {
|
"author": {
|
||||||
|
67
test.cjs
Normal file
67
test.cjs
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
const path = require("path");
|
||||||
|
const glob = require("glob");
|
||||||
|
const { runQunitPuppeteer, printFailedTests, printOutput } = require("node-qunit-puppeteer");
|
||||||
|
const { createServer } = require('vite');
|
||||||
|
|
||||||
|
const testFiles = glob.sync('test/*.html');
|
||||||
|
|
||||||
|
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;
|
||||||
|
};
|
||||||
|
|
||||||
|
// 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']
|
||||||
|
};
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
|
console.log(`\n${combinedResults.failed}/${combinedResults.total} tests 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);
|
||||||
|
};
|
||||||
|
|
||||||
|
// 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);
|
||||||
|
}
|
||||||
|
})();
|
Reference in New Issue
Block a user