├── .gitignore ├── tests ├── checkIfDivExists.js ├── checkDivBg.js └── checkDivAttribute.js ├── dist └── coolLibrary.js ├── .travis.yml ├── README.md ├── package.json └── my.conf.js /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules -------------------------------------------------------------------------------- /tests/checkIfDivExists.js: -------------------------------------------------------------------------------- 1 | describe('getDiv', function() { 2 | var d = document.querySelector('.box'); 3 | 4 | it('Should exist', function() { 5 | expect(d.nodeName).toBe('DIV'); 6 | }); 7 | }); -------------------------------------------------------------------------------- /tests/checkDivBg.js: -------------------------------------------------------------------------------- 1 | describe('getDivBg', function() { 2 | var d = document.querySelector('.box'); 3 | 4 | it('Should be teal', function() { 5 | expect(d.style.backgroundColor).toBe('teal'); 6 | }); 7 | }); -------------------------------------------------------------------------------- /dist/coolLibrary.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | var n = document.createElement('div'); 4 | n.style.backgroundColor = 'teal'; 5 | n.style.width = '250px'; 6 | n.style.height = '250px'; 7 | n.setAttribute('foo', 'bar'); 8 | n.classList.add('box'); 9 | document.body.appendChild(n); 10 | })(); -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "0.10" 4 | script: node_modules/karma/bin/karma start my.conf.js --single-run 5 | before_install: 6 | - export DISPLAY=:99.0 7 | - export CHROME_BIN=chromium-browser 8 | - sh -e /etc/init.d/xvfb start 9 | before_script: 10 | - npm install 11 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![Build Status](https://travis-ci.org/kyleladd/FEJStesting.svg) 2 | 3 | # FEJStesting 4 | Testing Front End Javascript with Karma, Jasmine, and Travis CLI 5 | 6 | ##This repo serves as an example to guide you in testing your front end javascript. 7 | 8 | ##Dependencies 9 | - Node 10 | - Karma 11 | - Jasmine 12 | - Travis CLI 13 | 14 | 15 | karma start my.conf.js --auto-watch 16 | karma run my.conf.js 17 | -------------------------------------------------------------------------------- /tests/checkDivAttribute.js: -------------------------------------------------------------------------------- 1 | describe('getDivAttribute', function() { 2 | var d = document.querySelector('.box'); 3 | 4 | it('Should be bar', function() { 5 | expect(d.getAttribute('foo')).toBe('bar'); 6 | }); 7 | }); 8 | describe('always true', function() { 9 | it('Should be bar', function() { 10 | expect(true).toBe(true); 11 | expect(false).toBe(false); 12 | }); 13 | it('Should be bar', function() { 14 | expect(true).toBe(true); 15 | expect(false).toBe(false); 16 | }); 17 | }); 18 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "FEJStesting", 3 | "version": "0.0.1", 4 | "description": "a sample testing setup", 5 | "repository": { 6 | "type": "git", 7 | "url": "https://github.com/tevko/FEJStesting.git" 8 | }, 9 | "keywords": [ 10 | "testing", 11 | "karma", 12 | "jasmin", 13 | "travis", 14 | "node" 15 | ], 16 | "author": "@tevko", 17 | "license": "MIT", 18 | "bugs": { 19 | "url": "https://github.com/tevko/FEJStesting/issues" 20 | }, 21 | "homepage": "https://github.com/tevko/FEJStesting", 22 | "devDependencies": { 23 | "jasmine-core": "^2.3.2", 24 | "karma": "^0.12.31", 25 | "karma-chrome-launcher": "^1.0.1", 26 | "karma-firefox-launcher": "^0.1.4", 27 | "karma-jasmine": "^0.3.5" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /my.conf.js: -------------------------------------------------------------------------------- 1 | // Karma configuration 2 | // Generated on Fri May 08 2015 21:55:21 GMT-0400 (Eastern Daylight Time) 3 | 4 | module.exports = function(config) { 5 | var configuration = { 6 | // base path that will be used to resolve all patterns (eg. files, exclude) 7 | basePath: '', 8 | 9 | 10 | // frameworks to use 11 | // available frameworks: https://npmjs.org/browse/keyword/karma-adapter 12 | frameworks: ['jasmine'], 13 | 14 | 15 | // list of files / patterns to load in the browser 16 | files: [ 17 | 'dist/*.js' , 'tests/*.js' 18 | ], 19 | 20 | 21 | // list of files to exclude 22 | exclude: [ 23 | ], 24 | 25 | 26 | // preprocess matching files before serving them to the browser 27 | // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor 28 | preprocessors: { 29 | }, 30 | 31 | 32 | // test results reporter to use 33 | // possible values: 'dots', 'progress' 34 | // available reporters: https://npmjs.org/browse/keyword/karma-reporter 35 | reporters: ['progress'], 36 | 37 | 38 | // web server port 39 | port: 9876, 40 | 41 | 42 | // enable / disable colors in the output (reporters and logs) 43 | colors: true, 44 | 45 | 46 | // level of logging 47 | // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG 48 | logLevel: config.LOG_INFO, 49 | 50 | 51 | // enable / disable watching file and executing tests whenever any file changes 52 | autoWatch: false, 53 | 54 | 55 | // start these browsers 56 | // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher 57 | 58 | customLaunchers: { 59 | Chrome_travis_ci: { 60 | base: 'Chrome', 61 | flags: ['--no-sandbox'] 62 | } 63 | }, 64 | 65 | // Continuous Integration mode 66 | // if true, Karma captures browsers, runs the tests and exits 67 | singleRun: false 68 | }; 69 | 70 | if(process.env.TRAVIS){ 71 | configuration.browsers = ['Chrome_travis_ci']; 72 | } 73 | else{ 74 | configuration.browsers = ['Firefox','Chrome']; 75 | } 76 | 77 | 78 | config.set(configuration); 79 | }; 80 | --------------------------------------------------------------------------------