From 78e7e28ff9c4e5956a388a174f5dcd636f9b9517 Mon Sep 17 00:00:00 2001 From: Jakob Linskeseder Date: Fri, 24 Dec 2021 00:22:45 +0100 Subject: [PATCH] Replace custom test-server with Grunt connect --- package.json | 2 +- tests/browser/playwright.config.js | 2 +- tests/server.js | 36 ------------------------------ 3 files changed, 2 insertions(+), 38 deletions(-) delete mode 100755 tests/server.js diff --git a/package.json b/package.json index 7cb06382..a588474d 100644 --- a/package.json +++ b/package.json @@ -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" diff --git a/tests/browser/playwright.config.js b/tests/browser/playwright.config.js index cff66297..84731b97 100644 --- a/tests/browser/playwright.config.js +++ b/tests/browser/playwright.config.js @@ -19,7 +19,7 @@ const config = { reporter: 'list', webServer: { command: 'npm run test:serve', - port: 3000, + port: 9999, reuseExistingServer: false } }; diff --git a/tests/server.js b/tests/server.js deleted file mode 100755 index db20b9d5..00000000 --- a/tests/server.js +++ /dev/null @@ -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);