UNPKG

2.08 kBJavaScriptView Raw
1/**
2 * This code is closed source and Confidential and Proprietary to
3 * Appcelerator, Inc. All Rights Reserved. This code MUST not be
4 * modified, copied or otherwise redistributed without express
5 * written permission of Appcelerator. This file is licensed as
6 * part of the Appcelerator Platform and governed under the terms
7 * of the Appcelerator license agreement.
8 */
9var exec = require('child_process').exec;
10
11module.exports = function(grunt) {
12
13 var tests = ['test/*_test.js'];
14
15 // Project configuration.
16 grunt.initConfig({
17 env: {
18 dev: {
19 APPC_TEST: '1'
20 },
21 cover: {
22 APPC_TEST: '1'
23 }
24 },
25 mochaTest: {
26 options: {
27 timeout: 3000,
28 reporter: 'spec',
29 ignoreLeaks: false,
30 globals: ['requestSSLHooks','requestSSLFingerprints']
31 },
32 src: tests
33 },
34 jshint: {
35 options: {
36 jshintrc: true
37 },
38 src: ['bin/appc','index.js', 'lib/**/*.js', 'test/**/*.js']
39 },
40 kahvesi: { src: tests },
41 clean: ['tmp']
42 });
43
44 // Load grunt plugins for modules
45 grunt.loadNpmTasks('grunt-mocha-test');
46 grunt.loadNpmTasks('grunt-contrib-jshint');
47 grunt.loadNpmTasks('grunt-contrib-clean');
48 grunt.loadNpmTasks('grunt-kahvesi');
49 grunt.loadNpmTasks('grunt-env');
50
51 // launch mock server
52 grunt.registerTask('prep', function() {
53 // make sure you don't load these modules before 'env' task, as
54 // some constants are set based on the environment variables.
55 //require('./index').log.level('warn');
56 //require('./test/mock-registry').listen(require('./lib/constants').TEST_PORT);
57 });
58
59 // compose our various coverage reports into one html report
60 grunt.registerTask('report', function() {
61 var done = this.async();
62 exec('./node_modules/grunt-kahvesi/node_modules/.bin/istanbul report html', function(err) {
63 if (err) { grunt.fail.fatal(err); }
64 grunt.log.ok('composite test coverage report generated at ./coverage/index.html');
65 return done();
66 });
67 });
68
69 grunt.registerTask('cover', ['clean', 'env:cover', 'prep', 'kahvesi', 'report']);
70 grunt.registerTask('default', ['clean', 'jshint', 'env:dev', 'prep', 'mochaTest']);
71
72};