Skip to content

Instantly share code, notes, and snippets.

@cayblood
Created November 13, 2014 01:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cayblood/dfce98a1a15c34208114 to your computer and use it in GitHub Desktop.
Save cayblood/dfce98a1a15c34208114 to your computer and use it in GitHub Desktop.
// Karma configuration
// Generated on Wed Nov 12 2014 16:58:10 GMT-0700 (MST)
module.exports = function(config) {
config.set({
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: 'app',
// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['jasmine'],
// list of files / patterns to load in the browser
files: [
'test/support/polymer_setup.js',
{pattern: 'bower_components/**', included: false, served: true},
{pattern: 'elements/**', included: false, served: true},
'test/**/*-spec.js',
'test/fixtures/*.html'
],
// list of files to exclude
exclude: [
],
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
'test/fixtures/*.html': 'html2js'
},
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['progress'],
// web server port
port: 9876,
// enable / disable colors in the output (reporters and logs)
colors: true,
// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,
// enable / disable watching file and executing tests whenever any file changes
autoWatch: true,
// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: ['Chrome'],
// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: false
});
};
Carls-MacBook-Pro:beehive carl$ ./node_modules/karma/bin/karma start karma.conf.js --single-run
INFO [karma]: Karma v0.12.24 server started at http://localhost:9876/
INFO [launcher]: Starting browser Chrome
INFO [Chrome 38.0.2125 (Mac OS X 10.10.0)]: Connected on socket W94OFEuw4CdgHVJQo-K6 with id 88824570
Chrome 38.0.2125 (Mac OS X 10.10.0) ERROR
Uncaught TypeError: Cannot read property 'parentNode' of undefined
at /Users/carl/Source/work/twt/beehive/app/bower_components/polymer/polymer.html:19
Chrome 38.0.2125 (Mac OS X 10.10.0) ERROR
Uncaught ReferenceError: Platform is not defined
at /Users/carl/Source/work/twt/beehive/app/bower_components/polymer/src/system/unresolved.js:30
// 1. Load Polymer before any code that touches the DOM.
var script = document.createElement("script");
script.src = "/base/bower_components/webcomponentsjs/webcomponents.js";
document.getElementsByTagName("head")[0].appendChild(script);
// 2. Load component(s)
var link = document.createElement("link");
link.rel = "import";
link.href = "/base/elements/twt-user-badge.html";
document.getElementsByTagName("head")[0].appendChild(link);
// Delay Jasmine specs until WebComponentsReady
var POLYMER_READY = false;
beforeEach(function(done) {
window.addEventListener('polymer-ready', function () {
POLYMER_READY = true;
done();
});
if (POLYMER_READY) done();
});
describe('<twt-user-badge>', function () {
describe('defaults', function () {
var container;
beforeEach(function () {
container = document.createElement("div");
container.innerHTML = __html__['test/fixtures/twt-user-badge.html'];
document.body.appendChild(container);
waits(0); // One event loop for elements to register in Polymer
});
afterEach(function () {
document.body.removeChild(container);
});
describe('<twt-user-badge>', function () {
it("should include the user's name", function () {
var el = document.querySelector('twt-user-badge');
expect(el.shadowRoot.textContent).toContain('George Stephanopoulos');
});
});
});
});
<script>
var user = {
name: 'George Stephanopoulos',
city: 'Copenhagen',
country: 'DK'
};
</script>
<twt-user-badge id="badge" user="{{user}}"></twt-user-badge>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment