Replace custom test-server with Grunt connect
This commit is contained in:
committed by
Jay Linski
parent
03d387bf8e
commit
78e7e28ff9
+1
-1
@@ -94,7 +94,7 @@
|
||||
"test:mocha": "grunt build && grunt test",
|
||||
"test:browser": "playwright test --config tests/browser/playwright.config.js tests/browser/spec.js",
|
||||
"test:integration": "grunt integration-tests",
|
||||
"test:serve": "node ./tests/server.js",
|
||||
"test:serve": "grunt connect:server:keepalive",
|
||||
"extensive-tests-and-publish-to-aws": "npx mocha tasks/tests/ && grunt --stack extensive-tests-and-publish-to-aws",
|
||||
"--- combined tasks ---": "",
|
||||
"check-before-pull-request": "concurrently --kill-others-on-fail npm:lint npm:test"
|
||||
|
||||
@@ -19,7 +19,7 @@ const config = {
|
||||
reporter: 'list',
|
||||
webServer: {
|
||||
command: 'npm run test:serve',
|
||||
port: 3000,
|
||||
port: 9999,
|
||||
reuseExistingServer: false
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
const fs = require('fs');
|
||||
const http = require('http');
|
||||
const path = require('path');
|
||||
|
||||
const mimeTypes = {
|
||||
css: 'text/css',
|
||||
html: 'text/html',
|
||||
js: 'text/javascript',
|
||||
json: 'application/json'
|
||||
};
|
||||
|
||||
// Serve static files for spec tests
|
||||
http
|
||||
.createServer(function(req, res) {
|
||||
const url = new URL(req.url, `http://${req.headers.host}`);
|
||||
let filePath = `${path.resolve(__dirname, '..')}${url.pathname}`;
|
||||
|
||||
if (fs.existsSync(filePath) && fs.statSync(filePath).isDirectory()) {
|
||||
filePath += filePath.endsWith('/') ? '' : '/';
|
||||
filePath += 'index.html';
|
||||
}
|
||||
|
||||
fs.readFile(filePath, function(err, data) {
|
||||
if (err) {
|
||||
res.writeHead(404);
|
||||
res.end(JSON.stringify(err));
|
||||
return;
|
||||
}
|
||||
|
||||
let mimeType = mimeTypes[filePath.split('.').pop()] || 'text/plain';
|
||||
|
||||
res.writeHead(200, { 'Content-Type': mimeType });
|
||||
res.end(data);
|
||||
});
|
||||
})
|
||||
.listen(3000);
|
||||
Reference in New Issue
Block a user