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
Run browser tests in firefox & chrome #173
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ const webpack = require("webpack"); | |
const glob = require("glob"); | ||
const path = require("path"); | ||
const CopyWebpackPlugin = require('copy-webpack-plugin'); | ||
const HardSourceWebpackPlugin = require("hard-source-webpack-plugin"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we really need this? It added a lot of unwanted side effects There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now, when but in hard-source-webpack-plugin is fixed (now @0.13.1), everything seems to run well. See, |
||
|
||
const testResourceDirs = glob.sync(path.join(__dirname, "@here/*/test/resources")); | ||
const testResources = testResourceDirs.map(dir => { return { | ||
|
@@ -37,6 +38,7 @@ const browserTestsConfig = { | |
filename: "[name].bundle.js" | ||
}, | ||
plugins: [ | ||
new HardSourceWebpackPlugin(), | ||
new webpack.EnvironmentPlugin({ | ||
// default NODE_ENV to development. Override by setting the environment variable NODE_ENV to 'production' | ||
NODE_ENV: process.env.NODE_ENV || "development" | ||
|
@@ -46,6 +48,7 @@ const browserTestsConfig = { | |
require.resolve("three/build/three.min.js"), | ||
require.resolve("mocha/mocha.js"), | ||
require.resolve("mocha/mocha.css"), | ||
require.resolve("mocha-webdriver-runner/dist/mocha-webdriver-client.js"), | ||
...testResources, | ||
{ from: path.join(harpFontResourcesPath, "resources"), to: "@here/harp-font-resources/resources" } | ||
]) | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe the problem was that some packages tried to be clever and add a "window" global variable, breaking this check for node.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Define "some packages".
As far as i know, testing for
process
is tricky as it's frequently used by e.qEnvironmentPlugin
and alike, but testing for window is good enough.On the other hand, the old code didn't passed our
yarn run tslint
check - and god knows how it succesfully passed CI.On the third hand, use of Function === eval, and we don't want it in code, even testing code. Unless really necessary (back to point 1).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sigh... Can't use process, because as soon as webpack sees it, it'll add some "convenience" code for you. As for "window" - make sure that there's no package in our stack that creates a global "window" variable (I forgot the details, but I believe there was at least one package that added "window" for node, that's why I added the additional
this === window
check)