-
Notifications
You must be signed in to change notification settings - Fork 27
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
Automate client tests with karma #126
Changes from 4 commits
22fe6e2
13dce6e
7cf1801
51167ad
d1f1e76
5b0bb10
8095e42
4207254
e54d865
c703435
710998c
925a898
27ac134
0dd1447
4f135ec
c12ff12
408c343
d6cc9a5
fe19d48
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,2 @@ | ||
reporting: | ||
dir: ./coverage/server |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,12 @@ | ||
language: node_js | ||
node_js: | ||
- "node" | ||
before_install: | ||
- export CHROME_BIN=chromium-browser | ||
- export DISPLAY=:99.0 | ||
- sh -e /etc/init.d/xvfb start | ||
after_success: | ||
- istanbul cover ./node_modules/mocha/bin/_mocha | ||
- cat ./coverage/lcov.info | ./node_modules/.bin/coveralls | ||
- karma start | ||
- lcov-result-merger 'coverage/**/lcov.info' 'coverage/fullCoverage.info' | ||
- cat ./coverage/fullCoverage.info | ./node_modules/.bin/coveralls |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Karma configuration | ||
|
||
module.exports = function(config) { | ||
var configuration = { | ||
basePath: '', | ||
frameworks: ['mocha'], | ||
files: [ | ||
'teddy.js', | ||
'test/models/*.js', | ||
'node_modules/chai/chai.js', | ||
'node_modules/chai-string/chai-string.js', | ||
{pattern: 'test/templates/**/*', included: false}, | ||
'test/*.js', | ||
'test/client.html' | ||
], | ||
reporters: ['progress', 'coverage'], | ||
port: 8000, | ||
proxies: { | ||
'/templates/': '/base/test/templates/', | ||
}, | ||
preprocessors: { | ||
'teddy.js': ['coverage'] | ||
}, | ||
coverageReporter: { | ||
type: 'lcov', | ||
dir: 'coverage/', | ||
subdir: function(browser) { | ||
return browser.toLowerCase().split(/[ /-]/)[0]; | ||
} | ||
}, | ||
colors: true, | ||
logLevel: config.LOG_INFO, | ||
autoWatch: false, | ||
singleRun: true, | ||
browsers: ['Chrome'], | ||
customLaunchers: { | ||
Chrome_travis_ci: { | ||
base: 'Chrome', | ||
flags: ['--no-sandbox'] | ||
} | ||
}, | ||
concurrency: 1 | ||
}; | ||
|
||
if (process.env.TRAVIS) { | ||
configuration.browsers = ['Chrome_travis_ci']; | ||
} | ||
|
||
config.set(configuration); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,14 +14,21 @@ | |
"dependencies": { | ||
}, | ||
"devDependencies": { | ||
"eslint": "3.13.1", | ||
"eslint": "3.19.0", | ||
"mocha": "3.2.0", | ||
"chai": "3.5.0", | ||
"chai-string": "1.3.0", | ||
"istanbul": "0.4.5", | ||
"mocha-lcov-reporter": "1.3.0", | ||
"coveralls": "2.12.0", | ||
"cross-env": "4.0.0" | ||
"coveralls": "2.13.0", | ||
"cross-env": "4.0.0", | ||
"karma": "1.6.0", | ||
"karma-cli": "1.0.1", | ||
"karma-mocha": "1.3.0", | ||
"karma-coverage": "1.1.1", | ||
"karma-chrome-launcher": "2.0.0", | ||
"karma-coverage-allsources": "0.0.4", | ||
"lcov-result-merger": "^1.2.0" | ||
}, | ||
"eslintConfig": { | ||
"env": { | ||
|
@@ -56,7 +63,8 @@ | |
"scripts": { | ||
"test": "cross-env NODE_ENV=test mocha --recursive test", | ||
"eslint": "eslint .", | ||
"cover": "cross-env NODE_ENV=cover istanbul cover _mocha --recursive test" | ||
"cover": "cross-env NODE_ENV=cover istanbul cover _mocha --recursive test", | ||
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. change 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. actually no, alias |
||
"karma": "karma start" | ||
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.
|
||
}, | ||
"pre-commit": [ | ||
"test", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -328,13 +328,21 @@ <h2>Warning: these tests can only be run from a web server.</h2> | |
<script src='../node_modules/mocha/mocha.js'></script> | ||
<script src='../node_modules/chai/chai.js'></script> | ||
<script src='../node_modules/chai-string/chai-string.js'></script> | ||
|
||
<!-- include mocha tests --> | ||
<script>mocha.setup('bdd');</script> | ||
<script src='conditionals.js'></script> | ||
<script src='includes.js'></script> | ||
<script src='looping.js'></script> | ||
<script src='misc.js'></script> | ||
|
||
<!-- run tests --> | ||
<script> | ||
var assert = chai.assert, | ||
templateList, | ||
templateLength, | ||
counter = 0, | ||
crossOriginError, | ||
request, | ||
i; | ||
|
||
templateList = [ | ||
|
@@ -417,7 +425,8 @@ <h2>Warning: these tests can only be run from a web server.</h2> | |
'misc/variableObjectProperty.html', | ||
'misc/emptyModelMarkup.html', | ||
'misc/infiniteIncludeTemplate.html', | ||
'misc/varNotInModel.html' | ||
'misc/varNotInModel.html', | ||
'misc/templateToMinify.html' | ||
]; | ||
templateLength = templateList.length; | ||
|
||
|
@@ -438,9 +447,11 @@ <h2>Warning: these tests can only be run from a web server.</h2> | |
if (crossOriginError) { | ||
crossOriginError.parentNode.removeChild(crossOriginError); | ||
} | ||
if (template === 'misc/templateToMinify.html') { | ||
teddy.minify(true); | ||
} | ||
teddy.templates[template] = teddy.compile(req.response || req.responseText); | ||
counter++; | ||
if (counter === templateLength) { | ||
if (counter++ === templateLength - 1) { | ||
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. clever but no |
||
mocha.run(); | ||
} | ||
} | ||
|
@@ -449,12 +460,5 @@ <h2>Warning: these tests can only be run from a web server.</h2> | |
})(i); | ||
} | ||
</script> | ||
|
||
<!-- run tests --> | ||
<script>mocha.setup('bdd');</script> | ||
<script src='conditionals.js'></script> | ||
<script src='includes.js'></script> | ||
<script src='looping.js'></script> | ||
<script src='misc.js'></script> | ||
</body> | ||
</html> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<!DOCTYPE html> | ||
<html lang='en'> | ||
<head> | ||
<meta charset='utf-8'> | ||
<meta name='viewport' content='width=device-width,initial-scale=1'> | ||
<meta name='format-detection' content='telephone=no'> | ||
<title>Plain HTML</title> | ||
</head> | ||
<body> | ||
<main> | ||
<p>This template contains no teddy tags. Just HTML.</p> | ||
</main> | ||
</body> | ||
</html> |
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.
any way to suppress this error?