mirror of
https://github.com/tenrok/OverlayScrollbars.git
synced 2026-05-31 21:04:06 +03:00
simplify test server setup
This commit is contained in:
@@ -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,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -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,
|
||||
}),
|
||||
]
|
||||
: []),
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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)}`)}`;
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
const path = require('path');
|
||||
|
||||
const { TEST_SERVER_PORT } = process.env;
|
||||
const port = TEST_SERVER_PORT ? Number(TEST_SERVER_PORT) : 8080;
|
||||
const deploymentConfig = path.resolve(__dirname, './config/jest-puppeteer.rollup.config.js');
|
||||
const testServerPath = path.resolve(__dirname, './config/jest-test-server.js');
|
||||
|
||||
process.env.TEST_SERVER_PORT = port;
|
||||
|
||||
module.exports = {
|
||||
browser: 'chromium',
|
||||
browserContext: 'incognito',
|
||||
@@ -13,8 +10,8 @@ module.exports = {
|
||||
headless: false,
|
||||
},
|
||||
server: {
|
||||
command: `cross-env TEST_SERVER_PORT=${port} node ${testServerPath}`,
|
||||
port,
|
||||
command: `node ${testServerPath}`,
|
||||
port: deploymentConfig.port,
|
||||
launchTimeout: 10000,
|
||||
},
|
||||
};
|
||||
|
||||
+2
-5
@@ -2,9 +2,9 @@ const path = require('path');
|
||||
const resolve = require('./resolve.config');
|
||||
const puppeteerRollupConfig = require('./config/jest-puppeteer.rollup.config.js');
|
||||
|
||||
const testEnvironmentPath = path.resolve(__dirname, './config/jest-puppeteer.env.js');
|
||||
const testServerLoaderPath = path.resolve(__dirname, './config/jest-test-server.loader.js');
|
||||
const jsdomSetupFile = path.resolve(__dirname, './config/jest-jsdom.setup.js');
|
||||
const puppeteerTestEnvironmentPath = path.resolve(__dirname, './config/jest-puppeteer.env.js');
|
||||
const puppeteerSetupFile = path.resolve(__dirname, './config/jest-puppeteer.setup.js');
|
||||
|
||||
// For a detailed explanation regarding each configuration property, visit:
|
||||
@@ -17,9 +17,6 @@ const base = {
|
||||
moduleDirectories: resolve.directories,
|
||||
moduleFileExtensions: resolve.extensions.map((ext) => ext.replace(/\./, '')),
|
||||
testPathIgnorePatterns: ['\\\\node_modules\\\\'],
|
||||
globals: {
|
||||
baseConfig: __filename,
|
||||
},
|
||||
};
|
||||
|
||||
const pptrBase = {
|
||||
@@ -27,7 +24,7 @@ const pptrBase = {
|
||||
preset: 'jest-puppeteer',
|
||||
setupFilesAfterEnv: ['expect-puppeteer', puppeteerSetupFile],
|
||||
testMatch: ['**/tests/puppeteer/**/*.test.[jt]s?(x)'],
|
||||
testEnvironment: testEnvironmentPath,
|
||||
testEnvironment: puppeteerTestEnvironmentPath,
|
||||
coveragePathIgnorePatterns: ['/node_modules/', `/${puppeteerRollupConfig.build}/`],
|
||||
transform: {
|
||||
'^.+\\.[jt]sx?$': 'babel-jest',
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
"bufferutil": "^4.0.1",
|
||||
"canvas": "^2.6.1",
|
||||
"core-js": "^3.6.5",
|
||||
"cross-env": "^7.0.2",
|
||||
"del": "^5.1.0",
|
||||
"eslint": "^7.5.0",
|
||||
"eslint-config-airbnb": "^18.2.0",
|
||||
|
||||
@@ -2634,13 +2634,6 @@ cosmiconfig@^6.0.0:
|
||||
path-type "^4.0.0"
|
||||
yaml "^1.7.2"
|
||||
|
||||
cross-env@^7.0.2:
|
||||
version "7.0.2"
|
||||
resolved "https://registry.yarnpkg.com/cross-env/-/cross-env-7.0.2.tgz#bd5ed31339a93a3418ac4f3ca9ca3403082ae5f9"
|
||||
integrity sha512-KZP/bMEOJEDCkDQAyRhu3RL2ZO/SUVrxQVI0G3YEQ+OLbRA3c6zgixe8Mq8a/z7+HKlNEjo8oiLUs8iRijY2Rw==
|
||||
dependencies:
|
||||
cross-spawn "^7.0.1"
|
||||
|
||||
cross-spawn@^3.0.0:
|
||||
version "3.0.1"
|
||||
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-3.0.1.tgz#1256037ecb9f0c5f79e3d6ef135e30770184b982"
|
||||
@@ -2660,7 +2653,7 @@ cross-spawn@^6.0.0, cross-spawn@^6.0.5:
|
||||
shebang-command "^1.2.0"
|
||||
which "^1.2.9"
|
||||
|
||||
cross-spawn@^7.0.0, cross-spawn@^7.0.1, cross-spawn@^7.0.2:
|
||||
cross-spawn@^7.0.0, cross-spawn@^7.0.2:
|
||||
version "7.0.3"
|
||||
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6"
|
||||
integrity sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==
|
||||
|
||||
Reference in New Issue
Block a user