Merge pull request #4924 from ErisDS/issue-2990-grunt-testem

Add grunt testem alias + some DRY in Gruntfile.js
This commit is contained in:
Sebastian Gierlinger 2015-02-18 19:53:52 +01:00
commit 2032410690

View File

@ -816,7 +816,7 @@ var _ = require('lodash'),
grunt.log.write('no test provided'); grunt.log.write('no test provided');
} }
grunt.task.run('setTestEnv', 'shell:test:' + test); grunt.task.run('test-setup', 'shell:test:' + test);
}); });
// ### Validate // ### Validate
@ -831,21 +831,30 @@ var _ = require('lodash'),
grunt.registerTask('validate', 'Run tests and lint code', grunt.registerTask('validate', 'Run tests and lint code',
['init', 'test-all']); ['init', 'test-all']);
// ### Test // ### Test-All
// **Main testing task** // **Main testing task**
// //
// `grunt test` will lint and test your pre-built local Ghost codebase. // `grunt test-all` will lint and test your pre-built local Ghost codebase.
// //
// `grunt test` runs jshint and jscs as well as the 4 test suites. See the individual sub tasks below for // `grunt test-all` runs jshint and jscs as well as all 6 test suites. See the individual sub tasks below for
// details of each of the test suites. // details of each of the test suites.
// //
grunt.registerTask('test-all', 'Run tests and lint code', grunt.registerTask('test-all', 'Run tests and lint code',
['jshint', 'jscs', 'test-routes', 'test-module', 'test-unit', 'test-integration', 'test-functional', 'shell:testem']); ['lint', 'test-routes', 'test-module', 'test-unit', 'test-integration', 'test-functional', 'shell:testem']
);
// ### Lint // ### Lint
// //
// `grunt lint` will run the linter and the code style checker so you can make sure your code is pretty // `grunt lint` will run the linter and the code style checker so you can make sure your code is pretty
grunt.registerTask('lint', 'Run the code style checks and linter', ['jshint', 'jscs']); grunt.registerTask('lint', 'Run the code style checks and linter',
['jshint', 'jscs']
);
// ### test-setup *(utility)(
// `grunt test-setup` will run all the setup tasks required for running tests
grunt.registerTask('test-setup', 'Setup ready to run tests',
['clean:test', 'setTestEnv', 'ensureConfig']
);
// ### Unit Tests *(sub task)* // ### Unit Tests *(sub task)*
// `grunt test-unit` will run just the unit tests // `grunt test-unit` will run just the unit tests
@ -865,7 +874,8 @@ var _ = require('lodash'),
// Unit tests do **not** touch the database. // Unit tests do **not** touch the database.
// A coverage report can be generated for these tests using the `grunt test-coverage` task. // A coverage report can be generated for these tests using the `grunt test-coverage` task.
grunt.registerTask('test-unit', 'Run unit tests (mocha)', grunt.registerTask('test-unit', 'Run unit tests (mocha)',
['clean:test', 'setTestEnv', 'ensureConfig', 'mochacli:unit']); ['test-setup', 'mochacli:unit']
);
// ### Integration tests *(sub task)* // ### Integration tests *(sub task)*
// `grunt test-integration` will run just the integration tests // `grunt test-integration` will run just the integration tests
@ -894,7 +904,8 @@ var _ = require('lodash'),
// //
// A coverage report can be generated for these tests using the `grunt test-coverage` task. // A coverage report can be generated for these tests using the `grunt test-coverage` task.
grunt.registerTask('test-integration', 'Run integration tests (mocha + db access)', grunt.registerTask('test-integration', 'Run integration tests (mocha + db access)',
['clean:test', 'setTestEnv', 'ensureConfig', 'mochacli:integration']); ['test-setup', 'mochacli:integration']
);
// ### Route tests *(sub task)* // ### Route tests *(sub task)*
// `grunt test-routes` will run just the route tests // `grunt test-routes` will run just the route tests
@ -915,7 +926,8 @@ var _ = require('lodash'),
// are working as expected, including checking the headers and status codes received. It is very easy and // are working as expected, including checking the headers and status codes received. It is very easy and
// quick to test many permutations of routes / urls in the system. // quick to test many permutations of routes / urls in the system.
grunt.registerTask('test-routes', 'Run functional route tests (mocha)', grunt.registerTask('test-routes', 'Run functional route tests (mocha)',
['clean:test', 'setTestEnv', 'ensureConfig', 'mochacli:routes']); ['test-setup', 'mochacli:routes']
);
// ### Module tests *(sub task)* // ### Module tests *(sub task)*
// `grunt test-module` will run just the module tests // `grunt test-module` will run just the module tests
@ -923,16 +935,13 @@ var _ = require('lodash'),
// The purpose of the module tests is to ensure that Ghost can be used as an npm module and exposes all // The purpose of the module tests is to ensure that Ghost can be used as an npm module and exposes all
// required methods to interact with it. // required methods to interact with it.
grunt.registerTask('test-module', 'Run functional module tests (mocha)', grunt.registerTask('test-module', 'Run functional module tests (mocha)',
['clean:test', 'setTestEnv', 'ensureConfig', 'mochacli:module']); ['test-setup', 'mochacli:module']
);
// ### Functional tests for the setup process // ### Ember unit tests *(sub task)*
// `grunt test-functional-setup will run just the functional tests for the setup page. // `grunt testem` will run just the ember unit tests
// grunt.registerTask('testem', 'Run the ember unit tests',
// Setup only works with a brand new database, so it needs to run isolated from the rest of ['test-setup', 'shell:testem']
// the functional tests.
grunt.registerTask('test-functional-setup', 'Run functional tests for setup',
['clean:test', 'setTestEnv', 'ensureConfig', 'cleanDatabase', 'express:test',
'spawnCasperJS:setup', 'express:test:stop']
); );
// ### Functional tests *(sub task)* // ### Functional tests *(sub task)*
@ -954,8 +963,16 @@ var _ = require('lodash'),
// The purpose of the functional tests is to ensure that Ghost is working as is expected from a user perspective // The purpose of the functional tests is to ensure that Ghost is working as is expected from a user perspective
// including buttons and other important interactions in the admin UI. // including buttons and other important interactions in the admin UI.
grunt.registerTask('test-functional', 'Run functional interface tests (CasperJS)', grunt.registerTask('test-functional', 'Run functional interface tests (CasperJS)',
['clean:test', 'setTestEnv', 'ensureConfig', 'cleanDatabase', 'express:test', 'spawnCasperJS', 'express:test:stop', ['test-setup', 'cleanDatabase', 'express:test', 'spawnCasperJS', 'express:test:stop', 'test-functional-setup']
'test-functional-setup'] );
// ### Functional tests for the setup process
// `grunt test-functional-setup will run just the functional tests for the setup page.
//
// Setup only works with a brand new database, so it needs to run isolated from the rest of
// the functional tests.
grunt.registerTask('test-functional-setup', 'Run functional tests for setup',
['test-setup', 'cleanDatabase', 'express:test', 'spawnCasperJS:setup', 'express:test:stop']
); );
// ### Coverage // ### Coverage
@ -968,7 +985,8 @@ var _ = require('lodash'),
// //
// Key areas for coverage are: helpers and theme elements, apps / GDK, the api and model layers. // Key areas for coverage are: helpers and theme elements, apps / GDK, the api and model layers.
grunt.registerTask('test-coverage', 'Generate unit and integration (mocha) tests coverage report', grunt.registerTask('test-coverage', 'Generate unit and integration (mocha) tests coverage report',
['clean:test', 'setTestEnv', 'ensureConfig', 'shell:coverage']); ['test-setup', 'shell:coverage']
);
// ## Building assets // ## Building assets
// //