Skip to content

Commit 19d898a

Browse files
jasonLasterjuliandescottes
authored andcommitted
Update Mocha runner
* remove component unit tests
1 parent 59694b4 commit 19d898a

15 files changed

+51
-291
lines changed

bin/dev-server.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,15 @@ const path = require("path");
44
const toolbox = require("devtools-launchpad/index");
55
const feature = require("devtools-config");
66
const getConfig = require("./getConfig");
7+
const { mochaWebpackConfig, startMochaServer } = require("./mocha-server")
8+
79

810
const envConfig = getConfig();
911
feature.setConfig(envConfig);
1012

11-
const webpackConfig = require("../webpack.config");
13+
let webpackConfig = require("../webpack.config");
14+
webpackConfig = mochaWebpackConfig(webpackConfig);
15+
1216
let { app } = toolbox.startDevServer(envConfig, webpackConfig, __dirname);
1317

1418
app.get("/integration", function(req, res) {
@@ -19,5 +23,7 @@ app.get("/integration/mocha.css", function(req, res) {
1923
res.sendFile(path.join(__dirname, "../node_modules/mocha/mocha.css"));
2024
});
2125

26+
startMochaServer(app)
27+
2228
console.log("View debugger examples here:")
2329
console.log("https://github.com/jasonLaster/debugger-examples")

bin/mocha-server.js

+14-23
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
const path = require("path");
55
const webpack = require("webpack");
66
const express = require("express");
7-
const projectConfig = require("../webpack.config");
87
const webpackDevMiddleware = require("webpack-dev-middleware");
98
const fs = require("fs");
9+
var serveStatic = require('serve-static')
1010

1111
function recursiveReaddirSync(dir) {
1212
let list = [];
@@ -37,31 +37,22 @@ function getTestPaths(dir) {
3737

3838
const testPaths = getTestPaths(path.join(__dirname, "../src"));
3939

40-
projectConfig.entry.bundle = projectConfig.entry.bundle.concat(testPaths);
41-
const config = Object.assign({}, projectConfig, {});
40+
function mochaWebpackConfig(projectConfig) {
41+
projectConfig.entry["debugger-unit-tests"] =
42+
projectConfig.entry.debugger.concat(testPaths);
4243

43-
const app = express();
44-
const compiler = webpack(config);
44+
return projectConfig;
45+
}
4546

46-
app.use(express.static("public"));
47-
app.use(express.static("node_modules"));
47+
function startMochaServer(app) {
48+
app.use("/examples", express.static("src/test/mochitest/examples"));
4849

49-
app.use(webpackDevMiddleware(compiler, {
50-
publicPath: projectConfig.output.publicPath,
51-
noInfo: true,
52-
stats: {
53-
colors: true
54-
}
55-
}));
50+
app.use(express.static("node_modules"));
5651

57-
app.get("/", function(req, res) {
58-
res.sendFile(path.join(__dirname, "../mocha-runner.html"));
59-
});
52+
app.get("/mocha", function(req, res) {
53+
res.sendFile(path.join(__dirname, "../mocha-runner.html"));
54+
});
6055

61-
app.listen(8003, "localhost", function(err, result) {
62-
if (err) {
63-
console.log(err);
64-
}
56+
}
6557

66-
console.log("Listening at http://localhost:8003");
67-
});
58+
module.exports = {mochaWebpackConfig, startMochaServer};

docs/local-development.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -363,8 +363,8 @@ $ yarn run test-all
363363

364364
* `yarn test` - Run tests headlessly
365365
* These are the basic unit tests which must always pass
366-
* `yarn run mocha-server` - Run tests in the browser once you open `http://localhost:8003`
367-
* This runs tests in the browser and is useful for fixing errors in the karma tests
366+
* `localhost:8000/mocha` - Run tests in the browser once you open `http://localhost:8003` [gif](http://g.recordit.co/Go1GOu1Pli.gif))
367+
368368

369369
#### Integration tests
370370

mocha-runner.html

+9-5
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,24 @@
22
<head>
33
<meta charset="utf-8">
44
<title>Mocha Tests</title>
5-
<link href="mocha/mocha.css" rel="stylesheet" />
5+
<link href="https://cdnjs.cloudflare.com/ajax/libs/mocha/3.2.0/mocha.css" rel="stylesheet" />
66
</head>
77
<body>
88
<div id="mocha"></div>
99

1010
<script src="https://cdn.rawgit.com/jquery/jquery/2.1.4/dist/jquery.min.js"></script>
11-
<script src="expect.js/index.js"></script>
12-
<script src="mocha/mocha.js"></script>
11+
<script src="https://cdnjs.cloudflare.com/ajax/libs/expect.js/0.2.0/expect.js"></script>
12+
<script src="https://cdnjs.cloudflare.com/ajax/libs/mocha/3.2.0/mocha.js"></script>
1313

1414
<script>mocha.setup('bdd')</script>
15-
<script src="assets/build/bundle.js"></script>
16-
<link rel="stylesheet" href="assets/build/styles.css">
15+
<script src="/assets/build/debugger-unit-tests.js"></script>
16+
<link rel="stylesheet" href="/assets/build/debugger.css">
17+
1718
<script>
1819
mocha.globals(['jQuery']);
20+
beforeEach(function() {
21+
localStorage.clear();
22+
})
1923
mocha.run();
2024
</script>
2125
</body>

package.json

-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
"lint-fix": "yarn run lint-js -- --fix",
2525
"test": "node src/test/node-unit-tests.js",
2626
"test-all": "yarn run test; yarn run lint; yarn run flow",
27-
"mocha-server": "node bin/mocha-server.js",
2827
"firefox": "./node_modules/.bin/start-firefox --start --location https://devtools-html.github.io/debugger-examples/",
2928
"chrome": "./node_modules/.bin/start-chrome",
3029
"copy-assets": "node bin/copy-assets",

src/actions/tests/sources.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const threadClient = {
3636
process.on("unhandledRejection", (reason, p) => {});
3737

3838
// Create a sourcemapped source that all the sourcemap tests can use.
39-
const bundleSource = makeSource("bundle.js", {
39+
const bundleSource = makeSource("sourcemaps/bundle.js", {
4040
sourceMapURL: "bundle.js.map"
4141
});
4242

src/components/test-utils.js

-46
This file was deleted.

src/components/tests/Breakpoints.js

-42
This file was deleted.

src/components/tests/Editor.js

-18
This file was deleted.

src/components/tests/Frames.js

-52
This file was deleted.

src/components/tests/Scopes.js

-28
This file was deleted.

src/components/tests/SourceTabs.js

-37
This file was deleted.

src/test/examples/statements.js

-25
This file was deleted.

0 commit comments

Comments
 (0)