Skip to content

Commit

Permalink
Update Mocha runner
Browse files Browse the repository at this point in the history
* remove component unit tests
  • Loading branch information
jasonLaster authored and juliandescottes committed Jan 13, 2017
1 parent 59694b4 commit 19d898a
Show file tree
Hide file tree
Showing 15 changed files with 51 additions and 291 deletions.
8 changes: 7 additions & 1 deletion bin/dev-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@ const path = require("path");
const toolbox = require("devtools-launchpad/index");
const feature = require("devtools-config");
const getConfig = require("./getConfig");
const { mochaWebpackConfig, startMochaServer } = require("./mocha-server")


const envConfig = getConfig();
feature.setConfig(envConfig);

const webpackConfig = require("../webpack.config");
let webpackConfig = require("../webpack.config");
webpackConfig = mochaWebpackConfig(webpackConfig);

let { app } = toolbox.startDevServer(envConfig, webpackConfig, __dirname);

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

startMochaServer(app)

console.log("View debugger examples here:")
console.log("https://github.com/jasonLaster/debugger-examples")
37 changes: 14 additions & 23 deletions bin/mocha-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
const path = require("path");
const webpack = require("webpack");
const express = require("express");
const projectConfig = require("../webpack.config");
const webpackDevMiddleware = require("webpack-dev-middleware");
const fs = require("fs");
var serveStatic = require('serve-static')

function recursiveReaddirSync(dir) {
let list = [];
Expand Down Expand Up @@ -37,31 +37,22 @@ function getTestPaths(dir) {

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

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

const app = express();
const compiler = webpack(config);
return projectConfig;
}

app.use(express.static("public"));
app.use(express.static("node_modules"));
function startMochaServer(app) {
app.use("/examples", express.static("src/test/mochitest/examples"));

app.use(webpackDevMiddleware(compiler, {
publicPath: projectConfig.output.publicPath,
noInfo: true,
stats: {
colors: true
}
}));
app.use(express.static("node_modules"));

app.get("/", function(req, res) {
res.sendFile(path.join(__dirname, "../mocha-runner.html"));
});
app.get("/mocha", function(req, res) {
res.sendFile(path.join(__dirname, "../mocha-runner.html"));
});

app.listen(8003, "localhost", function(err, result) {
if (err) {
console.log(err);
}
}

console.log("Listening at http://localhost:8003");
});
module.exports = {mochaWebpackConfig, startMochaServer};
4 changes: 2 additions & 2 deletions docs/local-development.md
Original file line number Diff line number Diff line change
Expand Up @@ -363,8 +363,8 @@ $ yarn run test-all

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


#### Integration tests

Expand Down
14 changes: 9 additions & 5 deletions mocha-runner.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,24 @@
<head>
<meta charset="utf-8">
<title>Mocha Tests</title>
<link href="mocha/mocha.css" rel="stylesheet" />
<link href="https://cdnjs.cloudflare.com/ajax/libs/mocha/3.2.0/mocha.css" rel="stylesheet" />
</head>
<body>
<div id="mocha"></div>

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

<script>mocha.setup('bdd')</script>
<script src="assets/build/bundle.js"></script>
<link rel="stylesheet" href="assets/build/styles.css">
<script src="/assets/build/debugger-unit-tests.js"></script>
<link rel="stylesheet" href="/assets/build/debugger.css">

<script>
mocha.globals(['jQuery']);
beforeEach(function() {
localStorage.clear();
})
mocha.run();
</script>
</body>
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
"lint-fix": "yarn run lint-js -- --fix",
"test": "node src/test/node-unit-tests.js",
"test-all": "yarn run test; yarn run lint; yarn run flow",
"mocha-server": "node bin/mocha-server.js",
"firefox": "./node_modules/.bin/start-firefox --start --location https://devtools-html.github.io/debugger-examples/",
"chrome": "./node_modules/.bin/start-chrome",
"copy-assets": "node bin/copy-assets",
Expand Down
2 changes: 1 addition & 1 deletion src/actions/tests/sources.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const threadClient = {
process.on("unhandledRejection", (reason, p) => {});

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

Expand Down
46 changes: 0 additions & 46 deletions src/components/test-utils.js

This file was deleted.

42 changes: 0 additions & 42 deletions src/components/tests/Breakpoints.js

This file was deleted.

18 changes: 0 additions & 18 deletions src/components/tests/Editor.js

This file was deleted.

52 changes: 0 additions & 52 deletions src/components/tests/Frames.js

This file was deleted.

28 changes: 0 additions & 28 deletions src/components/tests/Scopes.js

This file was deleted.

37 changes: 0 additions & 37 deletions src/components/tests/SourceTabs.js

This file was deleted.

25 changes: 0 additions & 25 deletions src/test/examples/statements.js

This file was deleted.

Loading

0 comments on commit 19d898a

Please sign in to comment.