Skip to content

Commit

Permalink
feat(config): Add configuration for adding javascript version.
Browse files Browse the repository at this point in the history
Add the configuration to add a javascript version tag to the loaded scripts. Only applied when the Firefox browser is run.

Closes karma-runner#1719
  • Loading branch information
Moumi committed Mar 8, 2016
2 parents 03e8d28 + 95c4754 commit f923811
Show file tree
Hide file tree
Showing 38 changed files with 585 additions and 250 deletions.
4 changes: 1 addition & 3 deletions docs/about/03-migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@ But hey, give it a shot first, it's really awesome to run your tests on every sa


## NPM complaining
In some cases NPM can run into dependency tree issues during the migration process. If you are faced
with an "unsatisfied peer dependency" error, removing all of the packages (`rm -rf ./node_modules`) and installing
them again should clear up the issue.
In some cases, NPM can run into dependency tree issues during the migration process. If you are faced with an "unsatisfied peer dependency" error, removing all of the packages (`rm -rf ./node_modules`) and installing them again should clear up the issue.

If you have any other issues, please ask on the [mailing list].

Expand Down
35 changes: 24 additions & 11 deletions docs/config/01-configuration-file.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ have occurred before starting the test process again.

**Description:** The root path location that will be used to resolve all relative
paths defined in `files` and `exclude`. If the `basePath` configuration is a
relative path then it will be resolved to the `__dirname` of the configuration file.
relative path, then it will be resolved to the `__dirname` of the configuration file.


## browserDisconnectTimeout
Expand All @@ -97,8 +97,8 @@ relative path then it will be resolved to the `__dirname` of the configuration f

**Description:** How long does Karma wait for a browser to reconnect (in ms).

With a flaky connection it is pretty common that the browser disconnects, but the actual test execution is still running
without any problems. Karma does not treat a disconnection as immediate failure and will wait `browserDisconnectTimeout` (ms).
With a flaky connection, it is pretty common that the browser disconnects, but the actual test execution is still running
without any problems. Karma does not treat a disconnection as an immediate failure and will wait for `browserDisconnectTimeout` (ms).
If the browser reconnects during that time, everything is fine.


Expand All @@ -110,7 +110,7 @@ If the browser reconnects during that time, everything is fine.
**Description:** The number of disconnections tolerated.

The `disconnectTolerance` value represents the maximum number of tries a browser will attempt in the case of a disconnection.
Usually any disconnection is considered a failure, but this option allows you to define a tolerance level when there is
Usually, any disconnection is considered a failure, but this option allows you to define a tolerance level when there is
a flaky network link between the Karma server and the browsers.


Expand All @@ -121,8 +121,7 @@ a flaky network link between the Karma server and the browsers.

**Description:** How long will Karma wait for a message from a browser before disconnecting from it (in ms).

If, during test execution, Karma does not receive any message from a browser within `browserNoActivityTimeout`
(ms), it will disconnect from the browser.
If, during test execution, Karma does not receive any message from a browser within `browserNoActivityTimeout`(ms), it will disconnect from the browser.


## browsers
Expand Down Expand Up @@ -172,8 +171,7 @@ it again and, after three attempts to capture it, Karma will give up.
are passed through to the test adapter as `karma.config.args` (an array of strings).
The `client.args` option allows you to set this value for actions other than `run`.

How this value is used is up to your test adapter - you should check your adapter's
documentation to see how (and if) it uses this value.
How this value is used is up to your test adapter - you should check your adapter's documentation to see how (and if) it uses this value.


## client.useIframe
Expand Down Expand Up @@ -203,7 +201,7 @@ iFrame and may need a new window to run.
**Description:** Clear the context window

If true, Karma clears the context window upon the completion of running the tests. If false, Karma does not clear the context window
upon the completion of running the tests. Setting this to false is useful when embedding a Jasmine Spec Runner Template.
upon the completion of running the tests. Setting this to false is useful when embedding a Jasmine Spec Runner Template.

## colors
**Type:** Boolean
Expand All @@ -220,9 +218,9 @@ upon the completion of running the tests. Setting this to false is useful when

**Default:** `Infinity`

**Description:** How many browser Karma launches in parallel.
**Description:** How many browsers Karma launches in parallel.

Especially on services like SauceLabs and Browserstack it makes sense to only launch a limited amount of browsers at once, and only start more when those have finished. Using this configuration you can specify how many browsers should be running at once at any given point in time.
Especially on services like SauceLabs and Browserstack, it makes sense only to launch a limited amount of browsers at once, and only start more when those have finished. Using this configuration, you can specify how many browsers should be running at once at any given point in time.


## customContextFile
Expand All @@ -241,6 +239,21 @@ Especially on services like SauceLabs and Browserstack it makes sense to only la
**Description:** If `null` (default), uses karma's own `debug.html` file.


## customContextFile
**Type:** string

**Default:** `null`

**Description:** If `null` (default), uses karma's own `context.html` file.


## customDebugFile
**Type:** string

**Default:** `null`

**Description:** If `null` (default), uses karma's own `debug.html` file.

## customHeaders
**Type:** Array

Expand Down
4 changes: 2 additions & 2 deletions docs/config/02-files.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,13 @@ files: [
],
```

The pattern is a glob which matches the specified image assets. Watched and included are not necessary as images are not tests. However they will need to be served to the browser.
The pattern is a glob which matches the specified image assets. Watched and included are not necessary as images are not tests. However, they will need to be served to the browser.

In this case an image would be accessed at `http://localhost:[PORT]/base/test/images/[MY IMAGE].jpg`

Notice the **base** in the URL, it is a reference to your **basePath**. You do not need to replace or provide your own **base**.

In addition you can use a proxy
In addition, you can use a proxy

```javascript
proxies: {
Expand Down
26 changes: 12 additions & 14 deletions docs/config/03-browsers.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Capturing browsers on your own can be a tedious and time consuming task,
Capturing browsers on your own can be a tedious and time-consuming task,
so Karma can automate this for you. Simply add the browsers you would like to
capture into the configuration file:

Expand All @@ -11,14 +11,14 @@ Then, Karma will take care of auto-capturing these browsers, as well as killing
Note: Most of the browser launchers need to be loaded as [plugins].

## Available browser launchers
- [Chrome and Chrome Canary] (install karma-chrome-launcher)
- [Firefox] (install karma-firefox-launcher first)
- [Safari] (install karma-safari-launcher first)
- [PhantomJS] (install karma-phantomjs-launcher)
- [Opera] (install karma-opera-launcher first)
- [IE] (install karma-ie-launcher first)
- [SauceLabs] (install karma-sauce-launcher)
- [BrowserStack] (install karma-browserstack-launcher)
- [Chrome and Chrome Canary](https://www.npmjs.com/package/karma-chrome-launcher)
- [Firefox](https://www.npmjs.com/package/karma-firefox-launcher)
- [Safari](https://www.npmjs.com/package/karma-safari-launcher)
- [PhantomJS](https://www.npmjs.com/package/karma-phantomjs-launcher)
- [Opera](https://www.npmjs.com/package/karma-opera-launcher)
- [IE](https://www.npmjs.com/package/karma-ie-launcher)
- [SauceLabs](https://www.npmjs.com/package/karma-saucelabs-launcher)
- [BrowserStack](https://www.npmjs.com/package/karma-browserstack-launcher)
- [many more](https://www.npmjs.org/browse/keyword/karma-launcher)

Here's an example of how to add Firefox to your testing suite:
Expand All @@ -38,7 +38,7 @@ module.exports = function(config) {
};
```

Also keep in mind that the `browsers` configuration setting is empty by default.
Also, keep in mind that the `browsers` configuration setting is empty by default.

Of course, you can write [custom plugins] too!

Expand All @@ -53,7 +53,7 @@ as the machine running Karma (or using a local tunnel).


## Configured launchers
Some of the launchers can be also configured:
Some of the launchers can also be configured:

```javascript
sauceLabs: {
Expand Down Expand Up @@ -126,9 +126,7 @@ browsers: ['/usr/local/bin/custom-browser.sh'],
// from cli
karma start --browsers /usr/local/bin/custom-browser.sh
```
The browser scripts need to take one argument, which is the URL with the ID
parameter to be used to connect to the server. The supplied ID is used
by the server to keep track of which specific browser is captured.
The browser scripts need to take one argument, which is the URL with the ID-parameter to be used to connect to the server. The supplied ID is used by the server to keep track of which specific browser is captured.



Expand Down
14 changes: 6 additions & 8 deletions docs/config/04-preprocessors.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Note: Most of the preprocessors need to be loaded as [plugins].
## Available Preprocessors
- [coffee]
- [html2js]
- Note any .html files listed in the files section must be referenced at run time as `window.__html__['template.html']`. [Learn more](html2js).
- Note any .html files listed in the files section must be referenced at run time as `window.__html__['template.html']`. [Learn more](https://github.com/karma-runner/karma-html2js-preprocessor#how-does-it-work-).
- If this preprocessor is disabled, included .html files will need `base/` added to beginning of their path reference. See [discussion in issue 788][issue788].
- [coverage]
- [ng-html2js]
Expand Down Expand Up @@ -47,7 +47,7 @@ Of course, you can write [custom plugins] too!


## Configured Preprocessors
Some of the preprocessors can be also configured:
Some of the preprocessors can also be configured:

```javascript
coffeePreprocessor: {
Expand All @@ -69,7 +69,7 @@ customPreprocessors: {
```


## Minimatching
## Mini matching
The keys of the preprocessors config object are used to filter the files specified in
the `files` configuration.

Expand Down Expand Up @@ -98,7 +98,7 @@ return `false` and the preprocessor would not be executed on the CoffeeScript fi

If a file matches only one key in the preprocessors config object, then karma
will execute the preprocessors over that file in the order they are listed in
the corresponding array. So for instance if the config object is:
the corresponding array. So for instance, if the config object is:

```js
preprocessors: {
Expand All @@ -118,9 +118,7 @@ preprocessors: {
}
```

then for `a.js`, karma will run `'a'` then `'b'` then `'c'`. If two lists
contradict eachother, like:

then for `a.js`, karma will run `'a'` then `'b'` then `'c'`. If two lists contradict each other, like:
```js
preprocessors: {
'*.js': ['a', 'b'],
Expand All @@ -139,4 +137,4 @@ preprocessors: {
```

Then `'a'` will definitely be run first, `'d'` will definitely be run last, but
it's arbitrarily if karma will run `'b'` before `'c'` or vice versa.
it's arbitrary if karma will run `'b'` before `'c'` or vice versa.
14 changes: 7 additions & 7 deletions docs/dev/01-contributing.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
pageTitle: Contributing to Karma

**Working on your first Pull Request?** You can learn how from this *free* series
[How to Contribute to an Open Source Project on GitHub](egghead_series)
[How to Contribute to an Open Source Project on GitHub]

You wanna contribute to Karma? That is truly great!
You want to contribute to Karma? That is truly great!
Here are some tips to get you started...

### Help others
Expand All @@ -16,17 +16,17 @@ Soon, you will realize you know Karma pretty well...


### Improve the documentation
You don’t feel like hacking on the code, but still wanna help?
You don’t feel like hacking on the code, but still want to help?
Improving the documentation is very valuable as it will help many others.

All the source code is in [`docs/`].


### Fix something that bothers you
You found a bug that really bothers you? It’s more likely it bothers other users too and maybe
Did you find a bug that really bothers you? It’s more likely it bothers other users too, and maybe
it’s not that hard to fix it! Try to find an existing issue. If it does not exist yet, create one.
Look into the code and let others know what solution you are thinking about.
Then, send a pull request and let other contributors to review.
Then, send a pull request and let other contributors review.

[Here](./making-changes.html) is some more info on how to set up your workspace and send a pull
request.
Expand All @@ -46,12 +46,12 @@ Check out the list of outstanding pull requests if there is something you might
Maybe somebody is trying to fix that stupid bug that bothers you. Review the PR.
Do you have any better ideas how to fix this problem? Let us know...

### I wanna help more
### I want to help more
Check out [Maintaining Karma]. Becoming a Karma maintainer is simple.
You just do it. There is no test to pass ;-)

[gitter]: https://gitter.im/karma-runner/karma
[Stack Overflow]: http://stackoverflow.com/questions/tagged/karma-runner
[`docs/`]: https://github.com/karma-runner/karma/tree/master/docs
[Maintaining Karma]: ./maintaining.html
[egghead_series]: https://egghead.io/series/how-to-contribute-to-an-open-source-project-on-github
[How to Contribute to an Open Source Project on GitHub]: https://egghead.io/series/how-to-contribute-to-an-open-source-project-on-github
2 changes: 1 addition & 1 deletion docs/dev/02-making-changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ your changes in.
## Contributor License Agreement
Please sign our Contributor License Agreement (CLA) before sending pull requests.
For any code changes to be accepted, the CLA must be signed. It's a quick process, we promise!
- For individuals we have a [simple click-through form].
- For individuals, we have a [simple click-through form].
- For corporations we'll need you to print, sign and one of scan+email, fax or mail [the form].

## Additional Resources
Expand Down
4 changes: 2 additions & 2 deletions docs/dev/03-maintaining.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ Every project has one or more owners (or “maintainers”), listed in `owners`

Being a maintainer of one plugin doesn’t mean you can’t contribute to some other plugins.
In fact, you can be a maintainer of multiple projects. The main point is to have people who are
familiar with the codebase and therefore can better decide what is a good change or not.
familiar with the codebase and therefore can better decide what a good change is or not.


## Becoming a maintainer
If you are interest in becoming a Karma maintainer, start by triaging issues, reviewing pull
If you are interested in becoming a Karma maintainer, start by triaging issues, reviewing pull
requests and stop by at [gitter/karma-runner]. Once we see you are helping, we will give you push
permissions. Being a maintainer is not an obligation. You can help when you have time and be less
active when you don’t. If you get a new job and get busy, that’s alright.
Expand Down
8 changes: 4 additions & 4 deletions docs/dev/04-public-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ A new browser was opened, but is not ready yet.
* `browser`: The browser instance
* `error`: The error that occurred

There was an error on this browser instance.
There was an error in this browser instance.

### `browser_start`
**Arguments:**
Expand Down Expand Up @@ -108,7 +108,7 @@ A test run was completed.

### **runner.run(options, [callback=process.exit])**

Equivalent of `karma run`.
The equivalent of `karma run`.

```javascript
var runner = require('karma').runner
Expand All @@ -122,7 +122,7 @@ runner.run({port: 9876}, function(exitCode) {

### **stopper.stop(options, [callback=process.exit])**

This function will signal a running server to stop. Equivalent of `karma stop`.
This function will signal a running server to stop. The equivalent of `karma stop`.

```javascript
var stopper = require('karma').stopper
Expand All @@ -136,4 +136,4 @@ runner.stop({port: 9876}, function(exitCode) {

## Callback function notes

- If there is an error, the error code will be provided as the second parameter to the error callback.
- If there is an error, the error code will be provided as the second parameter to the error callback.
6 changes: 3 additions & 3 deletions docs/dev/05-plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Karma can be extended through plugins. A plugin is essentially an NPM module. Ty
- user NPM keywords `karma-plugin`, `karma-preprocessor`

## Crazier stuff
Karma is assembled by Dependency Injection and a plugin is just an additional DI module (see [node-di] for more), that can be loaded by Karma. Therefore it can ask for pretty much any Karma component and interact with it. There are couple of plugins that do more interesting stuff like this, check out [karma-closure], [karma-intellij], [karma-dart].
Karma is assembled by Dependency Injection and a plugin is just an additional DI module (see [node-di] for more), that can be loaded by Karma. Therefore, it can ask for pretty much any Karma component and interact with it. There are a couple of plugins that do more interesting stuff like this, check out [karma-closure], [karma-intellij], [karma-dart].


[karma-jasmine]: https://github.com/karma-runner/karma-jasmine
Expand All @@ -43,7 +43,7 @@ Karma is assembled by Dependency Injection and a plugin is just an additional DI

## Karma Framework API

Karma Framework connect existing testing libraries to Karma's API, so that their
Karma Framework connects existing testing libraries to Karma's API, so that their
results can be displayed in a browser and sent back to the server.

Karma frameworks _must_ implement a `window.__karma__.start` method that Karma will
Expand All @@ -53,7 +53,7 @@ to send results back to karma:
* `.result` a single test has finished
* `.complete` the client completed execution of all the tests
* `.error` an error happened in the client
* `.info` other data (eg. number of tests or debugging messages)
* `.info` other data (e.g. number of tests or debugging messages)

Most commonly you'll use the `result` method to send individual test success or failure
statuses. The method takes an object of the form:
Expand Down
8 changes: 4 additions & 4 deletions docs/dev/06-git-commit-msg.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ showInMenu: false

## The reasons for these conventions:
- automatic generating of the changelog
- simple navigation through git history (eg. ignoring style changes)
- simple navigation through git history (e.g. ignoring style changes)

## Format of the commit message:
```bash
Expand All @@ -15,7 +15,7 @@ showInMenu: false


## Message subject (first line)
First line cannot be longer than 70 characters, second line is always blank and
The first line cannot be longer than 70 characters, the second line is always blank and
other lines should be wrapped at 80 characters. The type and scope should
always be lowercase as shown below.

Expand All @@ -39,7 +39,7 @@ always be lowercase as shown below.
* proxy
* etc.

The `<scope>` can be empty (eg. if the change is a global or difficult
The `<scope>` can be empty (e.g. if the change is a global or difficult
to assign to a single component), in which case the parentheses are
omitted. In smaller projects such as Karma plugins, the `<scope>` is empty.

Expand All @@ -61,7 +61,7 @@ Closed issues should be listed on a separate line in the footer prefixed with "C
```bash
Closes #234
```
or in case of multiple issues:
or in the case of multiple issues:
```bash
Closes #123, #245, #992
```
Expand Down
Loading

0 comments on commit f923811

Please sign in to comment.