forked from karma-runner/karma
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(config): Add configuration for adding javascript version.
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
Showing
7 changed files
with
137 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* eslint-disable no-unused-vars */ | ||
var isFirefox = function () { | ||
return typeof InstallTrigger !== 'undefined' | ||
} | ||
|
||
var containsJsTag = function () { | ||
var scripts = document.getElementsByTagName('script') | ||
for (var i = 0; i < scripts.length; i++) { | ||
if (scripts[i].type.indexOf(';version=') > -1) { | ||
return true | ||
} | ||
} | ||
return false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/* globals containsJsTag, isFirefox */ | ||
describe('JavaScript version tag', function () { | ||
it('should add the version tag, if Firefox is used', function () { | ||
expect(containsJsTag()).toBe(isFirefox()) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/* globals containsJsTag */ | ||
describe('JavaScript version tag', function () { | ||
it('should not add the version tag for every browser', function () { | ||
expect(containsJsTag()).toBe(false) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
Feature: JavaScript Tag | ||
In order to use Karma | ||
As a person who wants to write great tests | ||
I want to add a JavaScript version tag in Firefox only. | ||
|
||
Scenario: Execute a test in Firefox with version, with JavaScript tag | ||
Given a configuration with: | ||
""" | ||
files = ['tag/tag.js', 'tag/test-with-version.js']; | ||
browsers = ['Firefox'] | ||
jsVersion = 1.8 | ||
plugins = [ | ||
'karma-jasmine', | ||
'karma-firefox-launcher' | ||
] | ||
""" | ||
When I start Karma | ||
Then it passes with: | ||
""" | ||
. | ||
Firefox | ||
""" | ||
@not-jenkins | ||
Scenario: Execute a test in Chrome with version, without JavaScript tag | ||
Given a configuration with: | ||
""" | ||
files = ['tag/tag.js', 'tag/test-with-version.js']; | ||
browsers = ['Chrome']; | ||
jsVersion = 1.8; | ||
plugins = [ | ||
'karma-jasmine', | ||
'karma-chrome-launcher' | ||
]; | ||
""" | ||
When I start Karma | ||
Then it passes with: | ||
""" | ||
. | ||
Chrome | ||
""" | ||
|
||
Scenario: Execute a test in Firefox without version, without JavaScript tag | ||
Given a configuration with: | ||
""" | ||
files = ['tag/tag.js', 'tag/test-without-version.js']; | ||
browsers = ['Firefox'] | ||
plugins = [ | ||
'karma-jasmine', | ||
'karma-firefox-launcher' | ||
] | ||
""" | ||
When I start Karma | ||
Then it passes with: | ||
""" | ||
. | ||
Firefox | ||
""" | ||
@not-jenkins | ||
Scenario: Execute a test in Chrome without version, without JavaScript tag | ||
Given a configuration with: | ||
""" | ||
files = ['tag/tag.js', 'tag/test-without-version.js']; | ||
browsers = ['Chrome']; | ||
plugins = [ | ||
'karma-jasmine', | ||
'karma-chrome-launcher' | ||
]; | ||
""" | ||
When I start Karma | ||
Then it passes with: | ||
""" | ||
. | ||
Chrome | ||
""" | ||
|