Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

Commit

Permalink
Merge pull request #115 from jlongster/mocha-testing
Browse files Browse the repository at this point in the history
Improve mocha testing
  • Loading branch information
jlongster committed Apr 29, 2016
2 parents cd0ebfe + fdb624e commit 346ad41
Show file tree
Hide file tree
Showing 14 changed files with 95 additions and 114 deletions.
4 changes: 4 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{ "plugins": ["transform-es2015-block-scoping",
"transform-es2015-destructuring",
"transform-es2015-parameters",
"transform-es2015-spread"] }
76 changes: 0 additions & 76 deletions bin/test-node

This file was deleted.

31 changes: 25 additions & 6 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,27 @@
"use strict";

var webpackConfig = require('./webpack.config.js');
webpackConfig.entry = {};

// Compile with babel to support older browsers. We may be able to
// remove this if we can use latest versions that have enough ES6
// support.
webpackConfig.module.loaders.push({
test: /\.js$/,
exclude: /(node_modules|bower_components)/,
loader: "babel",
query: {
presets: ["es2015"],
plugins: ["transform-runtime"]
}
});

module.exports = function(config) {
const configuration = {
config.set({
basePath: "",
frameworks: ["mocha"],
files: [
// Uses the node test runner because babel is required
"public/build/test-bundle.js"
"./public/js/**/tests/*"
],
exclude: [],
preprocessors: {},
Expand All @@ -17,8 +32,12 @@ module.exports = function(config) {
logLevel: config.LOG_INFO,
autoWatch: false,
singleRun: false,
concurrency: Infinity
};
concurrency: Infinity,

preprocessors: {
"./public/js/**/tests/*": ['webpack']
},

config.set(configuration);
webpack: webpackConfig
});
};
15 changes: 11 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"start": "firefox-proxy & node bin/server",
"lint-css": "stylelint public/js/components/*.css",
"lint-js": "eslint public/js",
"test": "./bin/test-node public/js",
"test": "mocha --compilers js:babel-register public/js/**/tests/*",
"test-paths": "mocha --compilers js:babel-register",
"test-browser": "./bin/server-browser-test.js",
"test-karma": "./node_modules/.bin/karma start --single-run",
"storybook": "start-storybook -p 9001 -s public"
Expand All @@ -16,7 +17,7 @@
"co": "=4.6.0",
"codemirror": "^5.1.0",
"express": "^4.13.4",
"ff-devtools-libs": "^0.1.1",
"ff-devtools-libs": "=0.1.6",
"immutable": "^3.7.6",
"json-loader": "^0.5.4",
"karma": "^0.13.22",
Expand All @@ -38,17 +39,23 @@
"babel": "^6.5.2",
"babel-core": "^6.7.6",
"babel-loader": "^6.2.4",
"babel-polyfill": "^6.7.4",
"babel-plugin-transform-es2015-block-scoping": "^6.7.1",
"babel-plugin-transform-es2015-destructuring": "^6.6.5",
"babel-plugin-transform-es2015-parameters": "^6.7.0",
"babel-plugin-transform-es2015-spread": "^6.6.5",
"babel-plugin-transform-runtime": "^6.7.5",
"babel-preset-es2015": "^6.6.0",
"babel-register": "^6.7.2",
"css-loader": "^0.23.1",
"eslint": "^2.7.0",
"eslint-plugin-mozilla": "0.0.3",
"eslint-plugin-react": "^5.0.1",
"extract-text-webpack-plugin": "^1.0.1",
"expect.js": "^0.3.1",
"extract-text-webpack-plugin": "^1.0.1",
"karma-chrome-launcher": "^0.2.3",
"karma-firefox-launcher": "^0.1.7",
"karma-mocha": "^0.2.2",
"karma-webpack": "^1.7.0",
"rimraf": "^2.5.2",
"style-loader": "^0.13.1"
}
Expand Down
6 changes: 3 additions & 3 deletions public/js/actions/breakpoints.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";

const promise = require("devtools/sham/promise");
const promise = require("ff-devtools-libs/sham/promise");
const constants = require("../constants");
const { PROMISE } = require("devtools/client/shared/redux/middleware/promise");
const { PROMISE } = require("ff-devtools-libs/client/shared/redux/middleware/promise");
const {
getSource, getBreakpoint, getBreakpoints
} = require("../selectors");
const { Task } = require("devtools/sham/task");
const { Task } = require("ff-devtools-libs/sham/task");
const { fromJS } = require("immutable");

// Because breakpoints are just simple data structures, we still need
Expand Down
4 changes: 2 additions & 2 deletions public/js/actions/event-listeners.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

const constants = require("../constants");
const { asPaused } = require("../util/utils");
const { reportException } = require("devtools/shared/DevToolsUtils");
const { Task } = require("devtools/sham/task");
const { reportException } = require("ff-devtools-libs/shared/DevToolsUtils");
const { Task } = require("ff-devtools-libs/sham/task");

// delay is in ms
const FETCH_EVENT_LISTENERS_DELAY = 200;
Expand Down
10 changes: 5 additions & 5 deletions public/js/actions/sources.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";

const promise = require("devtools/sham/promise");
const { dumpn } = require("devtools/shared/DevToolsUtils");
const { PROMISE } = require("devtools/client/shared/redux/middleware/promise");
const { Task } = require("devtools/sham/task");
const SourceUtils = require("devtools/client/shared/source-utils");
const promise = require("ff-devtools-libs/sham/promise");
const { dumpn } = require("ff-devtools-libs/shared/DevToolsUtils");
const { PROMISE } = require("ff-devtools-libs/client/shared/redux/middleware/promise");
const { Task } = require("ff-devtools-libs/sham/task");
const SourceUtils = require("ff-devtools-libs/client/shared/source-utils");

const { getSource, getSourceText } = require("../selectors");
const constants = require("../constants");
Expand Down
4 changes: 2 additions & 2 deletions public/js/actions/tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* global window */
"use strict";
const { Task } = require("devtools/sham/task");
const { PROMISE } = require("devtools/client/shared/redux/middleware/promise");
const { Task } = require("ff-devtools-libs/sham/task");
const { PROMISE } = require("ff-devtools-libs/client/shared/redux/middleware/promise");

const { connectToTab} = require("../client");
const constants = require("../constants");
Expand Down
30 changes: 30 additions & 0 deletions public/js/actions/tests/breakpoints.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"use strict";

const { createStore } = require("../../util/test-head");
const { Task } = require("ff-devtools-libs/sham/task");
// const expect = require("expect.js");

const simpleMockThreadClient = {
source: function(form) {
return {
setBreakpoint: args => {
return new Promise((resolve, reject) => {
resolve({}, {
actor: form.actor
});
});
}
};
}
};

describe("breakpoints", () => {
it("should add a breakpoint", () => {
Task.spawn(function* () {
const store = createStore(simpleMockThreadClient);
return store;
// yield actions.addBreakpoint({ line: 5 });
// expect(queries.getBreakpoints(store.getState()).length).to.be(2);
});
});
});
4 changes: 2 additions & 2 deletions public/js/actions/tests/loadSourceText.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use strict";

const promise = require("devtools/sham/promise");
const { Task } = require("devtools/sham/task");
const promise = require("ff-devtools-libs/sham/promise");
const { Task } = require("ff-devtools-libs/sham/task");
const expect = require("expect.js");

const { actions, selectors, createStore } = require("../../util/test-head");
Expand Down
8 changes: 4 additions & 4 deletions public/js/client.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"use strict";

const { DebuggerClient } = require("devtools/shared/client/main");
const { DebuggerTransport } = require("devtools/transport/transport");
const { TargetFactory } = require("devtools/client/framework/target");
const promise = require("devtools/sham/promise");
const { DebuggerClient } = require("ff-devtools-libs/shared/client/main");
const { DebuggerTransport } = require("ff-devtools-libs/transport/transport");
const { TargetFactory } = require("ff-devtools-libs/client/framework/target");
const promise = require("ff-devtools-libs/sham/promise");
let currentClient = null;
let currentThreadClient = null;

Expand Down
8 changes: 4 additions & 4 deletions public/js/create-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

const { createStore, applyMiddleware } = require("redux");
const { thunk } = require("./util/thunk-middleware");
const { waitUntilService } = require("devtools/client/shared/redux/middleware/wait-service");
const { log } = require("devtools/client/shared/redux/middleware/log");
const { promise } = require("devtools/client/shared/redux/middleware/promise");
const { history } = require("devtools/client/shared/redux/middleware/history");
const { waitUntilService } = require("ff-devtools-libs/client/shared/redux/middleware/wait-service");
const { log } = require("ff-devtools-libs/client/shared/redux/middleware/log");
const { promise } = require("ff-devtools-libs/client/shared/redux/middleware/promise");
const { history } = require("ff-devtools-libs/client/shared/redux/middleware/history");

/**
* This creates a dispatcher with all the standard middleware in place
Expand Down
2 changes: 1 addition & 1 deletion public/js/prefs.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint max-len: [2, 90] */
"use strict";

const { PrefsHelper } = require("devtools/client/shared/prefs");
const { PrefsHelper } = require("ff-devtools-libs/client/shared/prefs");

/**
* Shortcuts for accessing various debugger preferences.
Expand Down
7 changes: 2 additions & 5 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,8 @@ let config = {
filename: "bundle.js"
},
resolve: {
alias: {
"devtools": "ff-devtools-libs",
"sdk": "ff-devtools-libs/sdk"
},
extensions: ["", ".js", ".jsm"],
// This is required to allow ff-devtools-libs to resolve modules
// to itself (all of its requires are absolute)
root: path.join(__dirname, "node_modules")
},
module: {
Expand Down

0 comments on commit 346ad41

Please sign in to comment.