diff options
author | Anike Arni <aarni@thoughtworks.com> | 2017-02-03 14:12:46 -0200 |
---|---|---|
committer | Anike Arni <aarni@thoughtworks.com> | 2017-02-03 14:14:29 -0200 |
commit | 2a0c02295ac6b3a21047e08a0174361003f02736 (patch) | |
tree | 2b76bc62af2e3930e624957ee9b05383db934810 /web-ui | |
parent | 16ce2be7e2a7496cedfe74bf27c72878941072cf (diff) |
[#922] Move new js tests to mocha
We decided to move to mocha because it has more support for node testing
with webpack (no need for browser). Since we're moving to React, we
don't need the browser for our unit tests. With @tayanefernandes
Diffstat (limited to 'web-ui')
-rw-r--r-- | web-ui/package.json | 9 | ||||
-rw-r--r-- | web-ui/test/spec/account_recovery/account_recovery.spec.js | 3 | ||||
-rw-r--r-- | web-ui/webpack.test.config.js | 34 |
3 files changed, 42 insertions, 4 deletions
diff --git a/web-ui/package.json b/web-ui/package.json index ec880270..6f875280 100644 --- a/web-ui/package.json +++ b/web-ui/package.json @@ -16,6 +16,7 @@ "css-loader": "^0.26.1", "dompurify": "^0.8.4", "enzyme": "^2.7.1", + "expect": "^1.20.2", "font-awesome": "^4.7.0", "handlebars": "^4.0.5", "he": "^1.1.0", @@ -25,13 +26,13 @@ "i18next-xhr-backend": "^1.2.1", "iframe-resizer": "^3.5.7", "imagemin": "5.2.1", - "jasmine": "^2.5.3", "jasmine-flight": "^4.0.0", "jasmine-jquery": "^2.1.1", "jquery": "^3.1.1", "jquery-file-upload": "^4.0.5", "jquery-ui": "^1.12.1", "jshint": "2.9.2", + "json-loader": "^0.5.4", "karma": "0.13.19", "karma-chrome-launcher": "0.2.2", "karma-coverage": "0.2.7", @@ -42,6 +43,8 @@ "karma-phantomjs-launcher": "1.0.1", "karma-requirejs": "1.0.0", "minify": "^2.0.13", + "mocha": "^3.2.0", + "mocha-webpack": "^0.7.0", "modernizr": "^3.3.1", "node-sass": "^4.5.0", "quoted-printable": "^1.0.1", @@ -57,8 +60,8 @@ "webpack": "^1.14.0" }, "scripts": { - "test": "npm run jshint --silent && npm run build-statics --silent && npm run jasmine-test && npm run karma-test", - "jasmine-test": "babel-node ./node_modules/.bin/jasmine JASMINE_CONFIG_PATH=test/jasmine.json", + "test": "npm run jshint --silent && npm run build-statics --silent && npm run mocha-test && npm run karma-test", + "mocha-test": "mocha-webpack --webpack-config webpack.test.config.js \"test/spec/account_recovery/**/*.spec.js\"", "karma-test": "karma start --single-run $GRUNT_OPTS", "debug": "npm run build && karma start --browsers Chrome $GRUNT_OPTS", "watch": "npm run compass-watch & npm run handlebars-watch & npm run build-js-watch", diff --git a/web-ui/test/spec/account_recovery/account_recovery.spec.js b/web-ui/test/spec/account_recovery/account_recovery.spec.js index d153f0eb..eaff257b 100644 --- a/web-ui/test/spec/account_recovery/account_recovery.spec.js +++ b/web-ui/test/spec/account_recovery/account_recovery.spec.js @@ -1,4 +1,5 @@ import {shallow} from 'enzyme' +import expect from 'expect' import React from 'react' import Page from '../../../app/js/account_recovery/page' @@ -6,6 +7,6 @@ describe('test', () => { 'use strict'; it('react', () => { const page = shallow(<Page />); - expect(page.find('h1').text()).toEqual('Hello world'); + expect(page.find('h1').text()).toEqual('E se vocĂȘ esquecer sua senha?'); }); }); diff --git a/web-ui/webpack.test.config.js b/web-ui/webpack.test.config.js new file mode 100644 index 00000000..d3b245fc --- /dev/null +++ b/web-ui/webpack.test.config.js @@ -0,0 +1,34 @@ +var path = require('path'); +var webpack = require('webpack'); +var copyWebpack = require('./config/copy-webpack'); +var aliases = require('./config/alias-webpack'); + +module.exports = { + resolve: { + alias: aliases, + extensions: ['', '.js'] + }, + externals: { + 'react/lib/ExecutionEnvironment': true, + 'react/addons': true, + 'react/lib/ReactContext': 'window' + }, + module: { + loaders: [ + { + test: /\.js$/, + exclude: /(node_modules|bower_components)/, + loader: 'babel', + query: { presets: ['es2015', 'react']} + }, + { + test: /\.scss|css$/, + loader: "css-loader!sass-loader" + }, + { + test: /\.json$/, + loader: "json-loader" + } + ] + } +} |