simplify test server setup

This commit is contained in:
Rene
2021-01-09 01:58:21 +01:00
parent 219c218f44
commit 2f80cac9e5
8 changed files with 23 additions and 31 deletions
+8
View File
@@ -1,4 +1,8 @@
const path = require('path');
module.exports = {
port: 8080,
root: path.join(__dirname, '../'),
build: '.build',
html: {
input: 'index.html',
@@ -8,4 +12,8 @@ module.exports = {
input: 'index.browser',
output: 'build',
},
dev: {
servePort: 18080,
livereloadPort: 28080,
},
};
+2 -3
View File
@@ -181,15 +181,14 @@ const setupRollupTest = async (rootDir, testPath, cacheDir, watch) => {
rollupPluginServe({
contentBase: dist,
historyApiFallback: `/${deploymentConfig.html.output}`,
port: 18080,
port: deploymentConfig.dev.servePort,
onListening(server) {
rollupServers.push(server);
},
}),
rollupPluginLivereload({
watch: dist,
verbose: true,
port: 28080,
port: deploymentConfig.dev.livereloadPort,
}),
]
: []),
+3 -4
View File
@@ -1,8 +1,7 @@
const path = require('path');
const express = require('express');
const deploymentConfig = require('./jest-puppeteer.rollup.config.js');
const app = express();
app.use(express.static(path.join(__dirname, '../')));
app.listen(process.env.TEST_SERVER_PORT);
app.use(express.static(deploymentConfig.root));
app.listen(deploymentConfig.port);
+4 -4
View File
@@ -1,10 +1,10 @@
const path = require('path');
const jestPuppeteerConfig = require('../jest-puppeteer.config.base');
const deploymentConfig = require('./jest-puppeteer.rollup.config.js');
module.exports = {
process: (src, filePath, config) => {
const deploymentPath = path.relative(path.dirname(config.globals.baseConfig), filePath);
process: (src, filePath) => {
const deploymentPath = path.relative(deploymentConfig.root, filePath);
const split = deploymentPath.split(path.sep);
return `module.exports = ${JSON.stringify(`http://localhost:${jestPuppeteerConfig.server.port}/${path.posix.join(...split)}`)}`;
return `module.exports = ${JSON.stringify(`http://localhost:${deploymentConfig.port}/${path.posix.join(...split)}`)}`;
},
};