Skip to content

Commit 4f57fd9

Browse files
committed
Testing and build changes
- Use Headless Chrome instead of PhantomJS - Reconfigure TravisCI - Remove lodash and use native functions instead - Remove redundant packages - Start partial migration to npm scripts instead of Grunt
1 parent b91df1f commit 4f57fd9

File tree

3 files changed

+29
-60
lines changed

3 files changed

+29
-60
lines changed

.travis.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
sudo: false
22
language: node_js
33
node_js:
4-
- "4"
4+
- "8"
5+
dist: trusty
6+
addons:
7+
chrome: stable
8+
cache:
9+
directories:
10+
- node_modules
511
script:
6-
- npm test
12+
- npm test

Gruntfile.js

Lines changed: 14 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
'use strict';
22

33
module.exports = function(grunt) {
4-
var _ = require('lodash');
54
var path = require('path');
65
var os = require('os');
76
var through = require('through2');
@@ -14,7 +13,7 @@ module.exports = function(grunt) {
1413

1514
var plugins = grunt.option('plugins');
1615
// Create plugin paths and verify they exist
17-
plugins = _.map(plugins ? plugins.split(',') : [], function(plugin) {
16+
plugins = (plugins ? plugins.split(',') : []).map(function(plugin) {
1817
var p = 'plugins/' + plugin + '.js';
1918

2019
if (!grunt.file.exists(p))
@@ -51,12 +50,12 @@ module.exports = function(grunt) {
5150
}
5251
};
5352

54-
var excluded = _.map(excludedPlugins, function(plugin) {
53+
var excluded = excludedPlugins.map(function(plugin) {
5554
return 'plugins/' + plugin + '.js';
5655
});
5756

5857
// Remove the plugins that we don't want to build
59-
a = _.filter(a, function(n) {
58+
a = a.filter(function(n) {
6059
return excluded.indexOf(n) === -1;
6160
});
6261

@@ -88,21 +87,17 @@ module.exports = function(grunt) {
8887
});
8988

9089
var pluginCombinations = combine(plugins);
91-
var pluginConcatFiles = _.reduce(
92-
pluginCombinations,
93-
function(dict, comb) {
94-
var key = _.map(comb, function(plugin) {
95-
return path.basename(plugin, '.js');
96-
});
97-
key.sort();
90+
var pluginConcatFiles = pluginCombinations.reduce(function(dict, comb) {
91+
var key = comb.map(function(plugin) {
92+
return path.basename(plugin, '.js');
93+
});
94+
key.sort();
9895

99-
var dest = path.join('build/', key.join(','), '/raven.js');
100-
dict[dest] = ['src/singleton.js'].concat(comb);
96+
var dest = path.join('build/', key.join(','), '/raven.js');
97+
dict[dest] = ['src/singleton.js'].concat(comb);
10198

102-
return dict;
103-
},
104-
{}
105-
);
99+
return dict;
100+
}, {});
106101

107102
var browserifyConfig = {
108103
options: {
@@ -202,30 +197,6 @@ module.exports = function(grunt) {
202197
}
203198
},
204199

205-
eslint: {
206-
target: ['.']
207-
},
208-
209-
mocha: {
210-
options: {
211-
mocha: {
212-
ignoreLeaks: true,
213-
grep: grunt.option('grep')
214-
},
215-
log: true,
216-
reporter: 'Dot',
217-
run: true
218-
},
219-
unit: {
220-
src: ['test/index.html'],
221-
nonull: true
222-
},
223-
integration: {
224-
src: ['test/integration/index.html'],
225-
nonull: true
226-
}
227-
},
228-
229200
release: {
230201
options: {
231202
npm: false,
@@ -338,12 +309,10 @@ module.exports = function(grunt) {
338309

339310
// 3rd party Grunt tasks
340311
grunt.loadNpmTasks('grunt-browserify');
341-
grunt.loadNpmTasks('grunt-mocha');
342312
grunt.loadNpmTasks('grunt-release');
343313
grunt.loadNpmTasks('grunt-s3');
344314
grunt.loadNpmTasks('grunt-gitinfo');
345315
grunt.loadNpmTasks('grunt-sri');
346-
grunt.loadNpmTasks('grunt-eslint');
347316

348317
// Build tasks
349318
grunt.registerTask('_prep', ['clean', 'gitinfo', 'version']);
@@ -355,7 +324,7 @@ module.exports = function(grunt) {
355324
'_prep',
356325
'browserify:plugins-combined'
357326
]);
358-
grunt.registerTask('build.test', ['_prep', 'browserify:test']);
327+
grunt.registerTask('build.test', ['_prep', 'browserify.core', 'browserify:test']);
359328
grunt.registerTask('build.core', ['browserify.core', 'uglify', 'sri:dist']);
360329
grunt.registerTask('build.plugins-combined', [
361330
'browserify.plugins-combined',
@@ -366,13 +335,9 @@ module.exports = function(grunt) {
366335
grunt.registerTask('build', ['build.plugins-combined']);
367336
grunt.registerTask('dist', ['build.core', 'copy:dist']);
368337

369-
// Test task
370-
grunt.registerTask('test', ['eslint', 'browserify.core', 'browserify:test', 'mocha']);
371-
372338
// Webserver tasks
373339
grunt.registerTask('run:test', ['connect:test']);
374340
grunt.registerTask('run:docs', ['connect:docs']);
375341

376-
grunt.registerTask('publish', ['test', 'build.plugins-combined', 's3']);
377-
grunt.registerTask('default', ['test']);
342+
grunt.registerTask('publish', ['build.plugins-combined', 's3']);
378343
};

package.json

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@
1717
"scripts": {
1818
"lint": "eslint .",
1919
"precommit": "lint-staged",
20-
"pretest": "npm install",
21-
"test": "grunt test && npm run-script test-typescript",
22-
"test-typescript": "node_modules/typescript/bin/tsc --noEmit --noImplicitAny typescript/raven-tests.ts"
20+
"publish": "npm run test && grunt publish",
21+
"test": "npm run lint && grunt build.test && npm run test:unit && npm run test:integration && npm run test:typescript",
22+
"test:unit": "mocha-chrome test/index.html",
23+
"test:integration": "mocha-chrome test/integration/index.html --chrome-flags '[\"--disable-web-security\"]' --ignore-resource-errors --ignore-exceptions",
24+
"test:typescript": "tsc --noEmit --noImplicitAny typescript/raven-tests.ts"
2325
},
2426
"devDependencies": {
2527
"bluebird": "^3.4.1",
@@ -28,27 +30,23 @@
2830
"chai": "2.3.0",
2931
"derequire": "2.0.3",
3032
"es6-promise": "^4.0.5",
33+
"eslint": "^4.6.1",
3134
"eslint-config-prettier": "^2.3.0",
3235
"grunt": "^0.4.5",
3336
"grunt-browserify": "^4.0.1",
3437
"grunt-cli": "^0.1.13",
3538
"grunt-contrib-clean": "^0.7.0",
36-
"grunt-contrib-concat": "^0.5.1",
3739
"grunt-contrib-connect": "^0.11.2",
3840
"grunt-contrib-copy": "^0.8.2",
39-
"grunt-contrib-jshint": "^0.11.3",
4041
"grunt-contrib-uglify": "^0.11.0",
41-
"grunt-eslint": "^20.0.0",
4242
"grunt-gitinfo": "^0.1.7",
43-
"grunt-mocha": "1.0.4",
4443
"grunt-release": "^0.13.0",
4544
"grunt-s3": "0.2.0-alpha.3",
4645
"grunt-sri": "mattrobenolt/grunt-sri#pretty",
4746
"husky": "^0.14.3",
48-
"jquery": "^2.1.4",
4947
"lint-staged": "^4.0.4",
50-
"lodash": "^3.10.1",
5148
"mocha": "2.5.3",
49+
"mocha-chrome": "^0.2.1",
5250
"prettier": "^1.6.1",
5351
"proxyquireify": "^3.0.2",
5452
"sinon": "1.7.3",

0 commit comments

Comments
 (0)