Skip to content

Commit 181f3cc

Browse files
authored
Merge pull request #249 from kmiller68/add-verbose-option-to-server
Add verbose option to the node server.
2 parents 53cefcd + 8c52642 commit 181f3cc

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

tests/run-browser.mjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
2525
// THE POSSIBILITY OF SUCH DAMAGE.
2626

27-
import serve from "./server.mjs";
27+
import { serve, optionDefinitions as serverOptionDefinitions } from "./server.mjs";
2828
import { Builder, Capabilities, logging } from "selenium-webdriver";
2929
import { Options as ChromeOptions } from "selenium-webdriver/chrome.js";
3030
import { Options as FirefoxOptions } from "selenium-webdriver/firefox.js";
@@ -80,8 +80,8 @@ function sleep(ms) {
8080
}
8181

8282
const optionDefinitions = [
83+
...serverOptionDefinitions,
8384
{ name: "browser", type: String, description: "Set the browser to test, choices are [safari, firefox, chrome, edge]. By default the $BROWSER env variable is used." },
84-
{ name: "port", type: Number, defaultValue: 8010, description: "Set the test-server port, The default value is 8010." },
8585
{ name: "help", alias: "h", description: "Print this help text." },
8686
{ name: "suite", type: String, defaultOption: true, typeLabel: `{underline choices}: ${VALID_TAGS.join(", ")}`, description: "Run a specific suite by name." }
8787
];
@@ -142,7 +142,7 @@ process.once("uncaughtException", (err) => {
142142
});
143143

144144
const PORT = options.port;
145-
const server = await serve(PORT);
145+
const server = await serve(options);
146146

147147
async function runTests() {
148148
let success = true;

tests/server.mjs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,21 @@ import LocalWebServer from "local-web-server";
2929

3030
const ROOT_DIR = path.join(process.cwd(), "./");
3131

32-
export default async function serve(port) {
32+
export const optionDefinitions = [
33+
{ name: "port", type: Number, defaultValue: 8010, description: "Set the test-server port, The default value is 8010." },
34+
{ name: "verbose", type: Boolean, defaultValue: false, description: "Log all requests set to the server." },
35+
];
36+
37+
export async function serve({ port, verbose }) {
3338
if (!port)
3439
throw new Error("Port is required");
40+
3541
const ws = await LocalWebServer.create({
3642
port: port,
3743
directory: ROOT_DIR,
3844
corsOpenerPolicy: "same-origin",
3945
corsEmbedderPolicy: "require-corp",
46+
logFormat: verbose ? "dev" : "none",
4047
});
4148
console.log(`Server started on http://localhost:${port}`);
4249
process.on("exit", () => ws.server.close());
@@ -48,11 +55,8 @@ export default async function serve(port) {
4855
}
4956

5057
function main() {
51-
const optionDefinitions = [
52-
{ name: "port", type: Number, defaultValue: 8010, description: "Set the test-server port, The default value is 8010." },
53-
];
5458
const options = commandLineArgs(optionDefinitions);
55-
serve(options.port);
59+
serve(options);
5660
}
5761

5862
if (esMain(import.meta))

0 commit comments

Comments
 (0)