Skip to content

Commit

Permalink
fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kwcantrell committed Aug 28, 2019
1 parent 08622f1 commit 9e574b9
Show file tree
Hide file tree
Showing 7 changed files with 160 additions and 108 deletions.
19 changes: 19 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
language: node_js
node_js:
- "10"
dist: trusty # needs Ubuntu Trusty
# Note: if you switch to sudo: false, you'll need to launch Chrome with --no-sandbox.
# See https://github.com/travis-ci/travis-ci/issues/8836
sudo: required
addons:
chrome: stable # have Travis install Chrome stable.
cache:
npm: false
directories:
- node_modules
script:
- npm install
#- npm install karma --save-dev
#- npm install karma-qunit karma-requirejs qunit requirejs karma-chrome-launcher --save-dev
- npm install -g karma-cli
- npm test
107 changes: 0 additions & 107 deletions empress/camera.js

This file was deleted.

83 changes: 83 additions & 0 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
// Karma configuration
// Generated on Tue Aug 27 2019 05:27:59 GMT-0700 (PDT)

module.exports = function(config) {
config.set({

// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '',


// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: [],


// list of files / patterns to load in the browser
files: [
/* QUnit */
'node_modules/qunit/qunit/qunit.js',
'node_modules/qunit/qunit/qunit.css',
'node_modules/karma-qunit/lib/adapter.js',

/* requireJS */
'node_modules/requirejs/require.js',
'node_modules/karma-requirejs/lib/adapter.js',

'tests/test-main.js',
{ pattern: 'tests/test-hello.js', included: false },

/* source and vendor js files for empress */
// { pattern: '../empress/support_files/js/*.js', included: false },
// { pattern: '../empress/support_files/vendor/*.js', included: false }
],


// list of files / patterns to exclude
exclude: [
],

// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
},


// 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: ['ChromeHeadless', 'Chrome'],
browsers: ['ChromeHeadless'],


// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: false,

// Concurrency level
// how many browser should be started simultaneous
concurrency: Infinity
})
}
16 changes: 16 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "headless-karma-travis",
"main": "tests/test-main.js",
"author": "Kalen Cantrell",
"scripts": {
"test": "karma start --single-run --browsers ChromeHeadless karma.conf.js"
},
"devDependencies": {
"karma": "^4.2.0",
"karma-chrome-launcher": "^3.1.0",
"karma-qunit": "^4.0.0",
"karma-requirejs": "^1.1.0",
"qunit": "^2.9.2",
"requirejs": "^2.3.6"
}
}
2 changes: 1 addition & 1 deletion tests/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
/* test paths */
'testBPTree' : './../tests/test-bp-tree',
'testByteTree' : './../tests/test-byte-array',
'testSidePanel' : './../tests/test-side-panel'
'testSidePanel' : './../tests/test-side-panel',
'testCamera' : './../tests/test-camera'
}
});
Expand Down
9 changes: 9 additions & 0 deletions tests/test-hello.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/* Hello world test for headless chrome test */

require([], function() {
// $(document).ready(function() {
QUnit.test('hello world', function(assert) {
assert.equal(1,1,'works');
});
// });
})
32 changes: 32 additions & 0 deletions tests/test-main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
var allTestFiles = []
var TEST_REGEXP = /test/

// Get a list of all the test files to include
// This will be usefull to only load tests files once the soure and vendor files
// are used
Object.keys(window.__karma__.files).forEach(function (file) {
if (TEST_REGEXP.test(file)) {
// console.log(file)
// Normalize paths to RequireJS module names.
// If you require sub-dependencies of test files to be loaded as-is (requiring file extension)
// then do not normalize the paths
var normalizedTestModule = file.replace(/^\/base\/|\.js$/g, '')
allTestFiles.push(normalizedTestModule)
}
})

// QUnit.config.autostart = false;
require.config({
// Karma serves files under /base, which is the basePath from your config file
baseUrl: '/base',

shim: {
'qunit' : {exports : 'qunit'}
},

// dynamically load all test files
deps: ['tests/test-hello'],

// we have to kickoff jasmine, as it is asynchronous
callback: window.__karma__.start
});

0 comments on commit 9e574b9

Please sign in to comment.