node_modules
env
dist
+coverage
npm run build &&
npm run build-tests &&
npm run test &&
+ npm run coverage &&
curl -O https://raw.githubusercontent.com/danvk/travis-weigh-in/master/weigh_in.py &&
python weigh_in.py dist/dygraph-combined.js
+++ /dev/null
-module.exports = function (config) {
- config.set({
- basePath: '../',
- frameworks: [
- 'mocha',
- 'chai'
- ],
- files: [
- 'dist/dygraph-combined-dev.js',
- 'src/extras/smooth-plotter.js',
- 'src/extras/synchronizer.js',
- 'auto_tests/data/*.js',
- 'auto_tests/tests/*.js',
- ],
- autoWatch: true,
- singleRun: false,
- reporters: ['mocha'], // or 'dots', 'mocha', 'spec'
- browsers: ['Chrome'], // or 'Firefox', 'Safari', etc.
- plugins: [
- 'karma-mocha',
- 'karma-chai-plugins',
- 'karma-chrome-launcher',
- 'karma-firefox-launcher',
- 'karma-spec-reporter',
- 'karma-mocha-reporter'
- ]
- });
-};
--- /dev/null
+<html>
+<head>
+ <meta charset="utf-8">
+ <title>dygraphs tests</title>
+ <link rel="stylesheet" href="../node_modules/mocha/mocha.css" />
+</head>
+<body>
+ <div id="graph"></div>
+ <div id="mocha"></div>
+
+ <!-- Polyfills for PhantomJS -->
+ <script src="../node_modules/babel-core/browser-polyfill.js"></script>
+
+ <!-- Mocha -->
+ <script src="../node_modules/mocha/mocha.js"></script>
+ <script src="../node_modules/chai/chai.js"></script>
+ <script>
+ if (window.initMochaPhantomJS) {
+ window.initMochaPhantomJS();
+ }
+ </script>
+
+ <script>
+ var expect = chai.expect;
+ var assert = chai.assert;
+ function cleanupAfterEach() {
+ // Clean up the DOM before each test.
+ // This makes debugging easier than cleaning up after each test, since the
+ // DOM stays on the screen after a failure.
+ beforeEach(function() {
+ var graph = document.getElementById('graph');
+ graph.innerHTML = '';
+ graph.setAttribute('style', '');
+ });
+ }
+ function useProxyCanvas(utils, Proxy) {
+ var _origFunc = utils.getContext;
+ beforeEach(function() {
+ utils.getContext = function(canvas) {
+ return new Proxy(_origFunc(canvas));
+ }
+ });
+
+ afterEach(function() {
+ utils.getContext = _origFunc;
+ });
+ }
+ </script>
+ <script>mocha.setup('bdd')</script>
+
+ <!-- Test data -->
+ <script src="data/data.js"></script>
+
+ <!-- Bundled tests -->
+ <script src="../coverage/tests.js"></script>
+
+ <script>
+ mocha.checkLeaks();
+ if (window.mochaPhantomJS) {
+ mochaPhantomJS.run();
+ } else {
+ mocha.run();
+ }
+ </script>
+</body>
+</html>
+++ /dev/null
-module.exports = function (config) {
- config.set({
- basePath: '../',
- frameworks: [
- 'mocha',
- 'chai'
- ],
- files: [
- 'dist/dygraph-combined-dev.js',
- 'src/extras/smooth-plotter.js',
- 'src/extras/synchronizer.js',
- 'auto_tests/data/*.js',
- 'auto_tests/tests/*.js',
- ],
- autoWatch: false,
- singleRun: true,
- reporters: ['mocha', 'coverage'], // or 'dots', 'mocha', 'spec'
- preprocessors: {
- 'dist/dygraph-combined-dev.js': ['coverage']
- },
- coverageReporter: {
- dir: 'dist/coverage',
- reporters: [
- { type: 'html', subdir: 'report-html' },
- { type: 'lcovonly', subdir: 'report-lcov' },
- ]
- },
- browsers: ['PhantomJS'],
- plugins: [
- 'karma-mocha',
- 'karma-chai-plugins',
- 'karma-phantomjs-launcher',
- 'karma-coverage',
- 'karma-spec-reporter',
- 'karma-mocha-reporter'
- ]
- });
-};
<script>
mocha.checkLeaks();
- mocha.run();
+ if (window.mochaPhantomJS) {
+ mochaPhantomJS.run();
+ } else {
+ mocha.run();
+ }
</script>
</body>
</html>
},
"homepage": "https://github.com/danvk/dygraphs",
"devDependencies": {
+ "babel": "^5.8.23",
"babel-core": "^5.8.25",
"babelify": "^6.3.0",
"browserify": "^11.2.0",
"envify": "^3.4.0",
"exorcist": "^0.4.0",
"http-server": "^0.8.5",
+ "istanbul": "^0.4.0",
"jshint": "^2.5.10",
"lcov-parse": "0.0.9",
"mocha": "^2.1.0",
- "mocha-phantomjs": "^4.0.1",
+ "mocha-phantomjs": "3.5.3",
+ "mocha-phantomjs-istanbul": "0.0.2",
"obvious-closure-library": "^20140401.0.2",
"parse-data-uri": "^0.2.0",
"phantomjs": "^1.9.7-8",
},
"scripts": {
"build": "./scripts/build.sh",
+ "coverage": "./scripts/generate-coverage.sh",
"watch": "./scripts/watch.sh",
"build-tests": "./scripts/build-tests.sh",
"test": "./scripts/run-tests.sh",
--- /dev/null
+#!/bin/bash
+# Generate code coverage data for posting to Coveralls.
+# This requires dist/*.js to be in place.
+# Output is coverage/lcov.info
+
+set -o errexit
+set -x
+
+# Generate per-file ES6 --> ES5 transpilations
+babel src --out-dir dist/src
+babel auto_tests/tests --out-dir dist/auto_tests/tests
+
+# Instrument the source code with Istanbul's __coverage__ variable.
+rm -rf coverage/* # Clear out everything to ensure a hermetic run.
+mkdir -p coverage
+istanbul instrument --output coverage/src dist/src
+cp -r dist/auto_tests coverage/
+
+# Build a combined file for running the tests in-browser
+browserify coverage/auto_tests/tests/*.js -o coverage/tests.js
+
+# Run http-server and save its PID for cleanup
+http-server > /dev/null &
+SERVER_PID=$!
+function finish() {
+ kill -TERM $SERVER_PID
+}
+trap finish EXIT
+
+# Give the server a chance to start up
+sleep 1
+
+# Run the tests using mocha-phantomjs & mocha-phantomjs-istanbul
+# This produces coverage/coverage.json
+phantomjs \
+ ./node_modules/mocha-phantomjs/lib/mocha-phantomjs.coffee \
+ http://localhost:8080/auto_tests/coverage.html \
+ spec '{"hooks": "mocha-phantomjs-istanbul", "coverageFile": "coverage/coverage.json"}'
+
+if [ $CI ]; then
+ # Convert the JSON coverage to LCOV for coveralls.
+ istanbul report --include coverage/*.json lcovonly
+
+ # Monkey patch in the untransformed source paths.
+ # perl -i -pe 's,dist/main,src/main,' coverage/lcov.info
+ echo '' # reset exit code -- failure to post coverage shouldn't be an error.
+
+else
+
+ # Convert the JSON coverage to HTML for viewing
+ istanbul report --include coverage/*.json html
+ set +x
+
+ echo 'To browse coverage, run:'
+ echo
+ echo ' open coverage/index.html'
+ echo
+
+fi
+++ /dev/null
-This is not the file you are looking for.
-A reasonably up-to-date version can be found at http://dygraphs.com/dygraph-combined.js
-
-dygraph-combined.js is a "packed" version of the larger dygraphs JS files. It is
-smaller and loads more quickly, but is harder to debug.
-
-To generate this file, run "make" or generate-combined.sh.