Skip to content

Commit

Permalink
Merge branch 'master' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
gnail authored Jul 10, 2016
2 parents 65b688a + e068fd2 commit 123a576
Show file tree
Hide file tree
Showing 13 changed files with 195 additions and 49 deletions.
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
<a name="1.1.1"></a>
## [1.1.1](https://github.com/karma-runner/karma/compare/v1.1.0...v1.1.1) (2016-07-07)


### Bug Fixes

* **executor:** ensure run_complete is emitted last ([9c894f9](https://github.com/karma-runner/karma/commit/9c894f9)), closes [#2210](https://github.com/karma-runner/karma/issues/2210)
* **reporter:** inject correct config option ([80bd726](https://github.com/karma-runner/karma/commit/80bd726))
* **reporter:** remove console.log ([b4e3694](https://github.com/karma-runner/karma/commit/b4e3694))
* Add crossorigin attribute to script HTML tags ([5690ffe](https://github.com/karma-runner/karma/commit/5690ffe))


### Features

* deprecate helper._ ([5c6b151](https://github.com/karma-runner/karma/commit/5c6b151))
* **config:** add support for TypeScript ([6445310](https://github.com/karma-runner/karma/commit/6445310))



<a name="1.1.0"></a>
# [1.1.0](https://github.com/karma-runner/karma/compare/v1.0.0...v1.1.0) (2016-06-26)

Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License

Copyright (C) 2011-2014 Google, Inc.
Copyright (C) 2011-2016 Google, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
Expand Down
67 changes: 67 additions & 0 deletions config.tpl.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// Karma configuration
// Generated on %DATE%

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

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


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


// list of files / patterns to load in the browser
files: [%FILES%
],


// list of files to exclude
exclude: [%EXCLUDE%
],


// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: %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: %AUTO_WATCH%,


// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: [%BROWSERS%],


// 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
})
}
13 changes: 13 additions & 0 deletions docs/config/01-configuration-file.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ Unless provided as argument, the Karma CLI will look for a configuration file at

* `./karma.conf.js`
* `./karma.conf.coffee`
* `./karma.conf.ts`
* `./.config/karma.conf.js`
* `./.config/karma.conf.coffee`
* `./.config/karma.conf.ts`

in that order.

Expand All @@ -40,6 +42,17 @@ module.exports = (config) ->
# ...
```

```typescript
# karma.conf.ts
module.exports = (config) => {
config.set({
basePath: '../..',
frameworks: ['jasmine'],
//...
});
}
```

## File Patterns
All of the configuration options, which specify file paths, use the [minimatch][minimatch] library to facilitate flexible
but concise file expressions so you can easily list all of the files you want to include and exclude.
Expand Down
4 changes: 4 additions & 0 deletions lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,14 @@ var processArgs = function (argv, options, fs, path) {
configFile = './karma.conf.js'
} else if (fs.existsSync('./karma.conf.coffee')) {
configFile = './karma.conf.coffee'
} else if (fs.existsSync('./karma.conf.ts')) {
configFile = './karma.conf.ts'
} else if (fs.existsSync('./.config/karma.conf.js')) {
configFile = './.config/karma.conf.js'
} else if (fs.existsSync('./.config/karma.conf.coffee')) {
configFile = './.config/karma.conf.coffee'
} else if (fs.existsSync('./.config/karma.conf.ts')) {
configFile = './.config/karma.conf.ts'
}
}

Expand Down
9 changes: 9 additions & 0 deletions lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ var _ = require('lodash')

var COFFEE_SCRIPT_AVAILABLE = false
var LIVE_SCRIPT_AVAILABLE = false
var TYPE_SCRIPT_AVAILABLE = false

// Coffee is required here to enable config files written in coffee-script.
// It's not directly used in this file.
Expand All @@ -24,6 +25,11 @@ try {
LIVE_SCRIPT_AVAILABLE = true
} catch (e) {}

try {
require('ts-node').register()
TYPE_SCRIPT_AVAILABLE = true
} catch (e) {}

var Pattern = function (pattern, served, included, watched, nocache) {
this.pattern = pattern
this.served = helper.isDefined(served) ? served : true
Expand Down Expand Up @@ -312,6 +318,9 @@ var parseConfig = function (configFilePath, cliOptions) {
} else if (extension === '.ls' && !LIVE_SCRIPT_AVAILABLE) {
log.error('You need to install LiveScript.\n' +
' npm install LiveScript --save-dev')
} else if (extension === '.ts' && !TYPE_SCRIPT_AVAILABLE) {
log.error('You need to install TypeScript.\n' +
' npm install typescript ts-node --save-dev')
}
}
return process.exit(1)
Expand Down
7 changes: 6 additions & 1 deletion lib/executor.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ var Executor = function (capturedBrowsers, config, emitter) {

if (capturedBrowsers.areAllReady(nonReady)) {
log.debug('All browsers are ready, executing')
log.debug('Captured %s browsers', capturedBrowsers.length)
executionScheduled = false
capturedBrowsers.clearResults()
capturedBrowsers.setAllToExecuting()
Expand Down Expand Up @@ -44,7 +45,11 @@ var Executor = function (capturedBrowsers, config, emitter) {
pendingCount--

if (!pendingCount) {
emitter.emit('run_complete', runningBrowsers, runningBrowsers.getResults())
// Ensure run_complete is emitted in the next tick
// so it is never emitted before browser_complete
setTimeout(function () {
emitter.emit('run_complete', runningBrowsers, runningBrowsers.getResults())
}, 0)
}
}

Expand Down
17 changes: 17 additions & 0 deletions lib/init/formatters.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ var COFFEE_REQUIREJS_TEMPLATE_PATH = path.join(__dirname, '/../../requirejs.conf
var COFFEE_REGEXP = /\.coffee$/
var LIVE_TEMPLATE_PATH = path.join(__dirname, '/../../config.tpl.ls')
var LIVE_REGEXP = /\.ls$/
var TYPE_TEMPLATE_PATH = path.join(__dirname, '/../../config.tpl.ts')
var TYPE_REGEXP = /\.ts$/

var isCoffeeFile = function (filename) {
return COFFEE_REGEXP.test(filename)
Expand All @@ -18,6 +20,10 @@ var isLiveFile = function (filename) {
return LIVE_REGEXP.test(filename)
}

var isTypeFile = function (filename) {
return TYPE_REGEXP.test(filename)
}

var JavaScriptFormatter = function () {
var quote = function (value) {
return "'" + value + "'"
Expand Down Expand Up @@ -114,9 +120,16 @@ var LiveFormatter = function () {
this.TEMPLATE_FILE_PATH = LIVE_TEMPLATE_PATH
}

var TypeFormatter = function () {
JavaScriptFormatter.call(this)

this.TEMPLATE_FILE_PATH = TYPE_TEMPLATE_PATH
}

exports.JavaScript = JavaScriptFormatter
exports.Coffee = CoffeeFormatter
exports.Live = LiveFormatter
exports.Type = TypeFormatter

exports.createForPath = function (path) {
if (isCoffeeFile(path)) {
Expand All @@ -127,5 +140,9 @@ exports.createForPath = function (path) {
return new LiveFormatter()
}

if (isTypeFile(path)) {
return new TypeFormatter()
}

return new JavaScriptFormatter()
}
2 changes: 1 addition & 1 deletion lib/middleware/karma.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ var urlparse = function (urlStr) {
var common = require('./common')

var VERSION = require('../constants').VERSION
var SCRIPT_TAG = '<script type="%s" src="%s"></script>'
var SCRIPT_TAG = '<script type="%s" src="%s" crossorigin="anonymous"></script>'
var LINK_TAG_CSS = '<link type="text/css" href="%s" rel="stylesheet">'
var LINK_TAG_HTML = '<link href="%s" rel="import">'
var SCRIPT_TYPE = {
Expand Down
2 changes: 1 addition & 1 deletion lib/reporters/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ BaseReporter.decoratorFactory.$inject = [
'formatError',
'config.reportSlowerThan',
'config.colors',
'config.browserLogOptions'
'config.browserConsoleLogOptions'
]

// PUBLISH
Expand Down
Loading

0 comments on commit 123a576

Please sign in to comment.