Skip to content
Permalink
Browse files

Mocha tests + many other small updates

  • Loading branch information
nicjansma committed Jan 21, 2015
1 parent a09ed76 commit 7d369d7d4f027f5678eed53b2b4642c61cd5cebd
@@ -2,8 +2,14 @@
*.gz
*.swp
boomerang-*.js
node_modules*
build/*
hint.log
tests/vendor/
tests/coverage/
*.diff
.project
.settings/
tests/vendor/
tests/coverage/
node_modules/
build/
@@ -2,174 +2,96 @@

"use strict";
module.exports = function (grunt) {

var src = [ "boomerang.js" ];
var plugins = grunt.file.readJSON("plugins.json");
src.push(plugins.plugins);
src.push("plugins/zzz_last_plugin.js");

grunt.initConfig({
pkg: grunt.file.readJSON("package.json"),
buildDate: Math.round(Date.now() / 1000),
builddate: Date.now(),
concat: {
options: {
stripBanners: false,
stripBanners: {
block : true,
line: true
},
seperator: ";"
},
debug: {
src: src,
dest: "build/<%= pkg.name %>-<%= pkg.releaseVersion %>.<%= buildDate %>-debug.js"
dest: "build/<%= pkg.name %>-<%= builddate %>-debug.js"
},
release: {
src: src,
dest: "build/<%= pkg.name %>-<%= pkg.releaseVersion %>.<%= buildDate %>.js"
dest: "build/<%= pkg.name %>-<%= builddate %>.js"
}
},
eslint: {
target: [
"Gruntfile.js",
"boomerang.js",
"plugins/*.js",
"tests/library/*.js"
"plugins/*.js"
]
},
"string-replace": {
all: {
files: [
{
src: "build/<%= pkg.name %>-<%= pkg.releaseVersion %>.<%= buildDate %>.js",
dest: "build/<%= pkg.name %>-<%= pkg.releaseVersion %>.<%= buildDate %>.js"
},
{
src: "build/<%= pkg.name %>-<%= pkg.releaseVersion %>.<%= buildDate %>-debug.js",
dest: "build/<%= pkg.name %>-<%= pkg.releaseVersion %>.<%= buildDate %>-debug.js"
}
],
options: {
replacements: [
{
// Replace 0.9 with 0.9.[date]
pattern: /BOOMR.version\s*=\s*".*";/,
replacement: "BOOMR.version = \"<%= pkg.releaseVersion %>.<%= buildDate %>\";"
},
{
// strip out BOOMR = BOOMR || {}; in plugins
pattern: /BOOMR\s*=\s*BOOMR\s*\|\|\s*{};/g,
replacement: ""
},
{
// strip out BOOMR.plugins = BOOMR.plugins || {}; in plugins
pattern: /BOOMR\.plugins\s*=\s*BOOMR\.plugins\s*\|\|\s*{};/g,
replacement: ""
}
]
}
},
debug: {
files: [{
src: "build/<%= pkg.name %>-<%= pkg.releaseVersion %>.<%= buildDate %>-debug.js",
dest: "build/<%= pkg.name %>-<%= pkg.releaseVersion %>.<%= buildDate %>-debug.js"
}],
options: {
replacements: [
{
// Add &debug key to request
pattern: /key=%client_apikey%/,
replacement: "debug=\&key=%client_apikey%"
}
]
}
},
release: {
files: [{
src: "build/<%= pkg.name %>-<%= pkg.releaseVersion %>.<%= buildDate %>.js",
dest: "build/<%= pkg.name %>-<%= pkg.releaseVersion %>.<%= buildDate %>.js"
}],
options: {
// strip out some NOPs
replacements: [
{
pattern: /else{}/g,
replacement: ""
},
{
pattern: /\(window\)\);/g,
replacement: "\(window\)\);\n"
},
{
pattern: /\(\)\);\(function\(/g,
replacement: "\(\)\);\n(function("
}
]
}
files: [{
src: "build/<%= pkg.name %>-<%= builddate %>.js",
dest: "build/<%= pkg.name %>-<%= builddate %>.js"
}],
options: {
replacements: [{
pattern: /else{}/g,
replacement: ""
},{
pattern: /\(window\)\);/g,
replacement: "\(window\)\);\n"
},{
pattern: /\(\)\);\(function\(/g,
replacement: "\(\)\);\n(function("
}]
}
}
},
copy: {
// copy files to -latest so test/index.html points to the latest version always
latest: {
files: [
{
nonull: true,
src: "build/<%= pkg.name %>-<%= pkg.releaseVersion %>.<%= buildDate %>-debug.js",
dest: "build/<%= pkg.name %>-latest-debug.js"
src: "build/<%= pkg.name %>-<%= builddate %>-debug.js",
dest: "build/<%= pkg.name %>-latest-debug.js",
},
{
nonull: true,
src: "build/<%= pkg.name %>-<%= pkg.releaseVersion %>.<%= buildDate %>-debug.min.js",
dest: "build/<%= pkg.name %>-latest-debug.min.js"
src: "build/<%= pkg.name %>-<%= builddate %>-debug.min.js",
dest: "build/<%= pkg.name %>-latest-debug.min.js",
},
{
nonull: true,
src: "build/<%= pkg.name %>-<%= pkg.releaseVersion %>.<%= buildDate %>-debug.min.js.map",
dest: "build/<%= pkg.name %>-latest-debug.min.js.map"
}
src: "build/<%= pkg.name %>-<%= builddate %>-debug.min.js.map",
dest: "build/<%= pkg.name %>-latest-debug.min.js.map",
},
]
}
},
uglify: {
options: {
options : {
preserveComments: false,
mangle: true,
mangle: false,
sourceMap: true
},
min_release: {
src: "build/<%= pkg.name %>-<%= pkg.releaseVersion %>.<%= buildDate %>.js",
dest: "build/<%= pkg.name %>-<%= pkg.releaseVersion %>.<%= buildDate %>.min.js"
report: "gzip",
src: "build/<%= pkg.name %>-<%= builddate %>.js",
dest: "build/<%= pkg.name %>-<%= builddate %>.min.js"
},
min_debug: {
src: "build/<%= pkg.name %>-<%= pkg.releaseVersion %>.<%= buildDate %>-debug.js",
dest: "build/<%= pkg.name %>-<%= pkg.releaseVersion %>.<%= buildDate %>-debug.min.js"
report: "gzip",
src: "build/<%= pkg.name %>-<%= builddate %>-debug.js",
dest: "build/<%= pkg.name %>-<%= builddate %>-debug.min.js"
}
},
compress: {
main: {
options: {
mode: "gzip",
level: 9
},
files: [
{
src: "build/<%= pkg.name %>-<%= pkg.releaseVersion %>.<%= buildDate %>.js",
dest: "build/<%= pkg.name %>-<%= pkg.releaseVersion %>.<%= buildDate %>.js.gz"
},
{
src: "build/<%= pkg.name %>-<%= pkg.releaseVersion %>.<%= buildDate %>-debug.js",
dest: "build/<%= pkg.name %>-<%= pkg.releaseVersion %>.<%= buildDate %>-debug.js.gz"
},
{
src: "build/<%= pkg.name %>-<%= pkg.releaseVersion %>.<%= buildDate %>.min.js",
dest: "build/<%= pkg.name %>-<%= pkg.releaseVersion %>.<%= buildDate %>.min.js.gz"
},
{
src: "build/<%= pkg.name %>-<%= pkg.releaseVersion %>.<%= buildDate %>-debug.min.js",
dest: "build/<%= pkg.name %>-<%= pkg.releaseVersion %>.<%= buildDate %>-debug.min.js.gz"
}
]
}
},
filesize: {
files: [ "build/<%= pkg.name %>-<%= pkg.releaseVersion %>.<%= buildDate %>.min.js.gz" ]
},
clean: {
options: {},
build: ["build/"],
@@ -179,7 +101,7 @@ module.exports = function (grunt) {
options: {
configFile: "./karma.config.js",
preprocessors: {
"./build/*.js": ["coverage"]
"./build/*.js": ["coverage"],
},
basePath: "./",
files: [
@@ -188,7 +110,7 @@ module.exports = function (grunt) {
"tests/vendor/chai/chai.js",
"tests/vendor/expect/index.js",
"tests/library/*.js",
"./build/<%= pkg.name %>-<%= pkg.releaseVersion %>.<%= buildDate %>.js"
"./build/<%= pkg.name %>-<%= builddate %>.js"
]
},
unit: {
@@ -211,12 +133,10 @@ module.exports = function (grunt) {
grunt.loadNpmTasks("grunt-contrib-uglify");
grunt.loadNpmTasks("grunt-contrib-clean");
grunt.loadNpmTasks("grunt-contrib-copy");
grunt.loadNpmTasks("grunt-contrib-compress");
grunt.loadNpmTasks("grunt-filesize");

grunt.registerTask("lint", "eslint");
grunt.registerTask("build", ["concat", "string-replace", "uglify", "compress", "copy:latest", "filesize"]);
grunt.registerTask("build", ["concat", "string-replace", "uglify", "copy:latest"]);
grunt.registerTask("test", ["build", "karma:unit"]);
grunt.registerTask("test:dev", ["build", "karma:dev"]);
grunt.registerTask("default", ["lint", "test"]);
grunt.registerTask("default", ["lint", "build", "test"]);
};
@@ -469,7 +469,7 @@ boomr = {
},

cleanupURL: function(url) {
if (!url) {
if (!url || Object.prototype.toString.call(url) === "[object Array]") {
return "";
}
if(impl.strip_query_string) {
@@ -684,7 +684,10 @@ boomr = {
document.body.appendChild(iframe);
document.body.appendChild(form);

form.submit();
try {
form.submit();
} catch (ignore) {
}

if (urls.length) {
BOOMR.setImmediate(submit);
@@ -25,6 +25,7 @@
],
"devDependencies": {
"chai": "~1.9.2",
"mocha": "~1.21.5"
"mocha": "~1.21.5",
"expect": "~0.3.1"
}
}
@@ -1,25 +1,21 @@
// Karma configuration
// Generated on %DATE%

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

basePath: "./",
config.set({
basePath: "./",

port: 4000,
runnerPort: 4001,
logLevel: config.LOG_INFO,
port: 4000,
runnerPort: 4001,
logLevel: config.LOG_INFO,

colors: false,
autoWatch: false,
colors: true,
autoWatch: false,

frameworks: ["mocha"],
reporters: ["progress","coverage"],
browsers: ['PhantomJS'],
frameworks: ["mocha"],
reporters: ["progress", "coverage"],
browsers: ["PhantomJS"],

coverageReporter: {
type : 'html',
dir : 'tests/coverage/'
}
});
coverageReporter: {
type : "html",
dir : "tests/coverage/"
}
});
};
@@ -21,7 +21,12 @@
"karma-chrome-launcher": "^0.1.5",
"karma-coverage": "^0.2.6",
"karma-mocha": "^0.1.9",
"karma-phantomjs-launcher": "^0.1.4"
"karma-phantomjs-launcher": "^0.1.4",
"karma-ie-launcher": "^0.1.5",
"karma-firefox-launcher": "^0.1.4",
"karma-opera-launcher": "^0.1.0",
"karma-safari-launcher": "^0.1.1",
"grunt-contrib-copy": "^0.7.0"
},
"scripts": {
"test": "grunt eslint"
@@ -4,7 +4,7 @@
"plugins/ipv6.js",
"plugins/clicks.js",
"plugins/mobile.js",
"plugins/restiming.js",
"plugins/restiming.js",
"plugins/cache-test-plugin.js",
"plugins/cache_reload.js",
"plugins/md5.js",
@@ -4,22 +4,29 @@
<title>Mocha</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- NOTE: If these change, update 04-plugins-restiming.js -->
<link rel="stylesheet" href="vendor/mocha/mocha.css" />
</head>
<body>
<div id="mocha"></div>
<script src="vendor/mocha/mocha.js"></script>
<script src="vendor/chai/chai.js"></script>
<script src="vendor/expect/index.js"></script>
<script>
mocha.setup('bdd');
</script>
<script src="../build/boomerang-0.9.0.js" type="text/javascript"></script>
<script src="library/00-logging.js"></script>
<script src="library/01-basic.js"></script>
<script src="library/02-utils.js"></script>
<script src="library/02-utils-cleanupurl.js"></script>
<script src="library/02-utils-hashquerystring.js"></script>
<script src="library/02-utils-objecttostring.js"></script>
<script src="library/02-utils-pluginconfig.js"></script>
<script src="library/02-utils-cookies.js"></script>
<script src="library/03-cookies.js"></script>
<script>
mocha.globals(["BOOMR"]);
mocha.globals(["BOOMR", "PageGroupVariable"]);
mocha.checkLeaks();
mocha.run();
</script>

0 comments on commit 7d369d7

Please sign in to comment.
You can’t perform that action at this time.