diff --git a/.gitignore b/.gitignore index 846a85955..ef2bae660 100644 --- a/.gitignore +++ b/.gitignore @@ -43,3 +43,5 @@ grunt/requirejs.js !.nvmrc !.prettierrc !.gitmodules + +test/test_manual.html \ No newline at end of file diff --git a/bower.json b/bower.json index 5b68ea9a9..7ad26429c 100644 --- a/bower.json +++ b/bower.json @@ -35,7 +35,6 @@ "qunit": "~1.12.0", "jasmine": "~1.3.1", "mocha": "~2.1.0", - "sinon": "1.9.0", "sprintf": "~1.0.2", "requirejs-babel": "^0.0.9", "d3-cloud": "^1.2.5" diff --git a/grunt/aliases.yaml b/grunt/aliases.yaml index 80b805ed2..32164e225 100644 --- a/grunt/aliases.yaml +++ b/grunt/aliases.yaml @@ -104,6 +104,13 @@ test:debug: - puppet:debug - clean:temp +generate-manual-testrunner: + - clean:temp + - babel:temp + - string-replace:temp + - generate-testrunner + - server + # Release release: description: Build the assets and prepare for a release diff --git a/grunt/concurrent.js b/grunt/concurrent.js index eeb9b03e4..718691abe 100644 --- a/grunt/concurrent.js +++ b/grunt/concurrent.js @@ -21,6 +21,7 @@ module.exports = { 'curl:deep-object-diff', 'curl:xstate-react', 'curl:array-flat-polyfill', + 'curl:sinon', ], hash_require: ['hash_require:js', 'hash_require:css'], }; diff --git a/grunt/curl.js b/grunt/curl.js index 340243271..5a68c1fcf 100644 --- a/grunt/curl.js +++ b/grunt/curl.js @@ -73,4 +73,8 @@ module.exports = { 'https://raw.githubusercontent.com/thostetler/array-flat-polyfill/master/index.js', dest: 'src/libs/polyfills/array-flat-polyfill.js', }, + sinon: { + src: 'https://cdnjs.cloudflare.com/ajax/libs/sinon.js/1.9.0/sinon.min.js', + dest: 'src/libs/sinon/index.js', + }, }; diff --git a/grunt/generate-testrunner.js b/grunt/generate-testrunner.js new file mode 100644 index 000000000..eb93c144d --- /dev/null +++ b/grunt/generate-testrunner.js @@ -0,0 +1,133 @@ +/* eslint-disable global-require */ +/** + * Options for the `test-manual` grunt task + * + * @module grunt/test-manual + */ + +module.exports = function(grunt) { + grunt.registerTask('generate-testrunner', function() { + const done = this.async(); + const path = require('path'); + const RUNNER_FILE_PATH = 'test/test_manual.html'; + + // grab all test files + const specs = grunt.file + .expand( + { + cwd: path.resolve('test/mocha/js/'), + }, + [ + '**/*.spec.js', + '!widgets/base_tree_view.spec.js', + '!widgets/facet_zoomable_graph_view.spec.js', + '!widgets/list_of_things_expanding.spec.js', + '!widgets/multi_callback_widget.spec.js', + '!widgets/similar_widget.spec.js', + '!widgets/green_button_widget.spec.js', + '!widgets/facet_graph_widget.spec.js', + '!js/apps/bumblebox/**/*.js', + ] + ) + .map((p) => p.replace(/^/, 'test/mocha/js/').replace(/.js$/, '')); + + // generate path mappings for transpiled modules + const mappings = grunt.file + .expand( + { + cwd: path.resolve('_tmp/js'), + }, + ['**/*.js'] + ) + .reduce((acc, m) => { + m = m.replace(/^/, 'js/').replace(/.js$/, ''); + acc[m] = m.replace(/^js\//, '_tmp/js/'); + return acc; + }, {}); + + const config = { + baseUrl: '../', + paths: mappings, + }; + + const testRunnerHTML = ` + + + Bumblebee Tests + + + + + +
+ + + + + + + +
+
+
+ + + `; + if (grunt.file.exists(RUNNER_FILE_PATH)) { + grunt.file.delete(RUNNER_FILE_PATH); + } + grunt.log.writeln('_tmp generated'); + grunt.file.write(RUNNER_FILE_PATH, testRunnerHTML); + grunt.log.writeln(`Test runner generated at ${RUNNER_FILE_PATH}`); + grunt.log.writeln( + `open browser to http://localhost:8000/${RUNNER_FILE_PATH}` + ); + done(); + }); +}; diff --git a/src/config/discovery.config.js b/src/config/discovery.config.js index c6061578f..e14e8ef30 100644 --- a/src/config/discovery.config.js +++ b/src/config/discovery.config.js @@ -301,7 +301,7 @@ require.config({ utils: 'js/utils', mocha: 'libs/mocha/mocha', chai: 'bower_components/chai/chai', - sinon: 'https://cdnjs.cloudflare.com/ajax/libs/sinon.js/1.9.0/sinon.min', + sinon: 'libs/sinon/index', suit: 'shared/dist/index.umd.development', yup: 'libs/yup/index', 'react-hook-form': [