This repository has been archived by the owner on Mar 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 197
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Common support for running tests (unit & integration) in browser using mocha-webdriver-runner. Initial support for firefox headless, with suspended support for headless Chrome due to bug [1]. [1]: puppeteer/puppeteer#3463
- Loading branch information
Showing
9 changed files
with
1,247 additions
and
295 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#!/usr/bin/env ts-node | ||
/* | ||
* Copyright (C) 2017-2018 HERE Europe B.V. | ||
* Licensed under Apache 2.0, see full license in LICENSE | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
declare const require: any; | ||
|
||
// tslint:disable:no-console | ||
|
||
// tslint:disable-next-line:no-var-requires | ||
const handler = require("serve-handler"); | ||
import * as child_process from "child_process"; | ||
import * as commander from "commander"; | ||
import * as http from "http"; | ||
import * as path from "path"; | ||
|
||
// tslint:disable-next-line:no-var-requires | ||
|
||
commander | ||
.usage("[options] COMMAND") | ||
.option("-p, --port <PORT>", "change port number", 8000) | ||
.option("-C, --dir <DIR>", "serve files from DIR", process.cwd()); | ||
|
||
commander.parse(process.argv); | ||
const command = commander.args; | ||
if (command.length < 1) { | ||
commander.outputHelp(); | ||
throw new Error("with-http-server: COMMAND needed"); | ||
} | ||
|
||
const dir = path.resolve(process.cwd(), commander.opts().dir); | ||
const server = http.createServer((request, response) => { | ||
if (request.url === "/") { | ||
request.url = "/index.html"; | ||
} | ||
const serveHandlerOptions = { | ||
cleanUrls: false, | ||
public: dir | ||
}; | ||
return handler(request, response, serveHandlerOptions); | ||
}); | ||
|
||
const port: number = commander.opts().port || 8000; | ||
|
||
server.listen(port, () => { | ||
console.error(`with-http-server: Serving ${dir} at http://localhost:${port}`); | ||
const cmdFile = command.shift(); | ||
const cmdArgs = command; | ||
console.error(`with-http-server: Running ${cmdFile} ${cmdArgs.join(" ")}`); | ||
const child = child_process.spawn(cmdFile!, cmdArgs, { | ||
shell: true, | ||
stdio: "inherit" | ||
}); | ||
|
||
child.on("close", code => { | ||
console.log(`with-http-server: child process exited with code ${code}`); | ||
process.exit(code); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"compilerOptions": { | ||
"module": "commonjs", | ||
"target": "es2017", | ||
"target": "es5", | ||
"lib": [ | ||
"es2017", | ||
"dom" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.