-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make tests work with Karma and Chrome (Closes #60) #67
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
6 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
language: node_js | ||
sudo: required | ||
dist: trusty | ||
addons: | ||
apt: | ||
sources: | ||
google-chrome | ||
packages: | ||
google-chrome-stable | ||
before_install: | ||
- export DISPLAY=:99.0 | ||
- sh -e /etc/init.d/xvfb start | ||
- sleep 3 # give xvfb some time to start | ||
- export CHROME_BIN=google-chrome | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,12 +19,19 @@ module.exports = function(config) { | |
}, | ||
{ pattern: 'node_modules/react-dom/dist/react-dom.js', included: false }, | ||
{ pattern: 'node_modules/rxjs/bundles/Rx.umd.js', included: false }, | ||
{ pattern: 'node_modules/chrono-node/chrono.min.js', included:false }, | ||
{ pattern: 'node_modules/moment/moment.js', included: false }, | ||
{ pattern: 'node_modules/twitter_cldr/min/*.js', included: false }, | ||
'tests/unit/test-main.js', | ||
], | ||
|
||
// Test results reporter to use. | ||
reporters: ['mocha'], | ||
|
||
mochaReporter: { | ||
showDiff: true, | ||
}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we can have nice things |
||
|
||
// Web server port. | ||
port: 9876, | ||
|
||
|
@@ -42,7 +49,7 @@ module.exports = function(config) { | |
|
||
// Start these browsers, available browser launchers: | ||
// https://npmjs.org/browse/keyword/karma-launcher | ||
browsers: ['Firefox'], | ||
browsers: ['Chrome'], | ||
|
||
|
||
// Continuous Integration mode, if true, Karma captures browsers, runs the | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -98,6 +98,6 @@ | |
"sinon-chai": "^2.8.0", | ||
"stylelint": "^6.5.1", | ||
"stylelint-config-standard": "^8.0.0", | ||
"uglify-js": "github:mishoo/UglifyJS2#harmony" | ||
"uglify-js": "github:mishoo/UglifyJS2#766fafda8baefe6d150df27dfad7e99857c08557" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. waiting for mishoo/UglifyJS#1229 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: Can we make a GitHub issue and mention the related issue? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. filed #68 |
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"env": { | ||
"mocha": true, | ||
"node": true, | ||
}, | ||
"globals": { | ||
"assert": true, | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import moment from 'components/moment'; | ||
import IntentParser from 'js/lib/intent-parser'; | ||
|
||
describe('intent-parser', function() { | ||
describe('Properly parses expected reminder sentences', function() { | ||
const fixtures = [ | ||
{ | ||
sentence: 'Remind me to go to the office by 5pm', | ||
parsed: { | ||
users: ['me'], | ||
action: 'go to the office', | ||
confirmation: | ||
'OK, I\'ll remind you to go to the office at 5 PM today.', | ||
time: moment({ hour: 17 }).toDate(), | ||
}, | ||
}, | ||
{ | ||
sentence: 'Remind John by tomorrow to take out trash', | ||
parsed: { | ||
users: ['John'], | ||
action: 'take out trash', | ||
confirmation: | ||
'OK, I\'ll remind John to take out trash at 12 PM tomorrow.', | ||
time: moment({ hour: 12 }).add(1, 'day').toDate(), | ||
}, | ||
}, | ||
]; | ||
|
||
fixtures.forEach(({ sentence, parsed }) => { | ||
it(sentence, function() { | ||
const intentParser = new IntentParser(); | ||
return intentParser.parse(sentence).then((result) => { | ||
assert.deepEqual(result, parsed); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* eslint no-var: "off" */ | ||
|
||
var allTestFiles = []; | ||
var TEST_REGEXP = /(spec|test)\.js$/i; | ||
|
||
// Get a list of all the test files to include | ||
Object.keys(window.__karma__.files).forEach(function(file) { | ||
if (TEST_REGEXP.test(file)) { | ||
// Normalize paths to RequireJS module names. | ||
allTestFiles.push(file.replace(/^\/base\/|\.js$/g, '')); | ||
} | ||
}); | ||
|
||
require.config({ | ||
// Karma serves files under /base, which is the basePath from config file. | ||
baseUrl: '/base', | ||
deps: allTestFiles, | ||
callback: window.__karma__.start, | ||
|
||
// ReactDOM expects "react" module to be defined, but it is not. | ||
map: { | ||
'*': { | ||
'react': 'components/react', | ||
}, | ||
}, | ||
|
||
paths: { | ||
'js': 'dist/tests/unit', | ||
// Addons include React TestUtils. | ||
'components/react': 'node_modules/react/dist/react-with-addons', | ||
'components/react-dom': 'node_modules/react-dom/dist/react-dom', | ||
'components/chrono': 'node_modules/chrono-node/chrono.min', | ||
'components/moment': 'node_modules/moment/moment', | ||
'components/cldr/core': 'node_modules/twitter_cldr/min/core.min', | ||
'components/cldr/en': 'node_modules/twitter_cldr/min/en.min', | ||
'rxjs': 'node_modules/rxjs/bundles/Rx.umd', | ||
}, | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
otherwise an older chromium is used