diff --git a/.babelrc b/.babelrc new file mode 100644 index 0000000000..0578679419 --- /dev/null +++ b/.babelrc @@ -0,0 +1,3 @@ +{ + "presets": ["react", "es2015"] +} diff --git a/karma.conf.js b/karma.conf.js new file mode 100644 index 0000000000..a859e34edb --- /dev/null +++ b/karma.conf.js @@ -0,0 +1,39 @@ +// karma.conf.js +var webpack = require('webpack'); +var path = require('path'); + +module.exports = function (config) { + config.set({ + browsers: ['Chrome'], + singleRun: true, + frameworks: ['mocha'], + files: [ + 'tests/tests.js' + ], + preprocessors: { + 'tests/tests.js': ['webpack', 'sourcemap'] + }, + reporters: ['dots'], + webpack: { + module: { + loaders: [ + { test: /\.json$/, loader: "json" }, + { test: /\.js$/, loader: "babel", include: path.resolve('./src') }, + ], + noParse: [ + // don't parse the languages within highlight.js. They + // cause stack overflows + // (https://github.com/webpack/webpack/issues/1721), and + // there is no need for webpack to parse them - they can + // just be included as-is. + /highlight\.js\/lib\/languages/, + ], + }, + resolve: { + alias: { + 'matrix-react-sdk': path.resolve('src/index.js'), + }, + }, + }, + }); +}; diff --git a/package.json b/package.json index d2e9c32d74..60ff7f7b05 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,9 @@ "build": "babel src -d lib --source-maps", "start": "babel src -w -d lib --source-maps", "clean": "rimraf lib", - "prepublish": "npm run build; git rev-parse HEAD > git-revision.txt" + "prepublish": "npm run build; git rev-parse HEAD > git-revision.txt", + "test": "karma start", + "test-multi": "karma start --single-run=false" }, "dependencies": { "classnames": "^2.1.2", @@ -45,6 +47,15 @@ "json-loader": "^0.5.3", "require-json": "0.0.1", "rimraf": "^2.4.3", - "source-map-loader": "^0.1.5" + "source-map-loader": "^0.1.5", + + "karma": "^0.0.0", + "karma-cli": "^0.0.0", + "karma-mocha": "^0.0.0", + "karma-webpack": "^0.0.0", + "karma-sourcemap-loader": "^0.0.0", + "karma-chrome-launcher": "^0.0.0", + "mocha": "^0.0.0", + "expect": "^0.0.0" } } diff --git a/tests/components/structures/MatrixChat-test.js b/tests/components/structures/MatrixChat-test.js new file mode 100644 index 0000000000..917dbcba18 --- /dev/null +++ b/tests/components/structures/MatrixChat-test.js @@ -0,0 +1,11 @@ +var React = require('react'); +var expect = require('expect'); + +var sdk = require("matrix-react-sdk"); + +var MatrixChat = sdk.getComponent('structures.MatrixChat'); + +describe('MatrixChat', function () { + it('does something', function () { + }); +}); diff --git a/tests/tests.js b/tests/tests.js new file mode 100644 index 0000000000..5a2a44909b --- /dev/null +++ b/tests/tests.js @@ -0,0 +1,11 @@ +// tests.js +// +// Our master test file: uses the webpack require API to find our test files +// and run them + +// this is a handly place to make sure the sdk has been skinned +var sdk = require("matrix-react-sdk"); +sdk.loadSkin(require('../src/component-index')); + +var context = require.context('.', true, /-test\.jsx?$/); +context.keys().forEach(context);