diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..20fd7a19 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,3 @@ +[*.js] +indent_style=space +indent_size=4 diff --git a/.gitignore b/.gitignore index d48db0e7..e9ba91e2 100644 --- a/.gitignore +++ b/.gitignore @@ -41,3 +41,6 @@ nosetests.xml .pydevproject .vagrant + +# Node +node_modules/ diff --git a/.travis.yml b/.travis.yml index 77b52ef5..559895df 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,11 @@ python: os: - linux -# - osx + +cache: + directories: + - $HOME/.cache/pip + - node_modules sudo: false @@ -16,9 +20,11 @@ install: - pip install git+https://github.com/esnme/ultrajson.git - python setup.py -q install - pip install coverage pytest-cov coveralls --use-mirrors + - npm install script: - python setup.py test + - python setup.py test + - cd karma-tests && make test after_success: coveralls diff --git a/karma-tests/Makefile b/karma-tests/Makefile new file mode 100644 index 00000000..bb80eeec --- /dev/null +++ b/karma-tests/Makefile @@ -0,0 +1,4 @@ +NODE_BIN_DIR=../node_modules/.bin + +test: + $(NODE_BIN_DIR)/karma start --single-run diff --git a/karma-tests/karma.conf.js b/karma-tests/karma.conf.js new file mode 100644 index 00000000..b40190f2 --- /dev/null +++ b/karma-tests/karma.conf.js @@ -0,0 +1,90 @@ +if (!process.env['SAUCE_USERNAME'] || !process.env['SAUCE_ACCESS_KEY']) { + console.error('Sauce Labs account details not set, skipping Karma tests'); + process.exit(0); +} + +var sauceLabsConfig = { + testName: 'PyWB Client Tests', +}; + +// see https://github.com/karma-runner/karma-sauce-launcher/issues/73 +if (process.env.TRAVIS_JOB_NUMBER) { + sauceLabsConfig.startConnect = false; + sauceLabsConfig.tunnelIdentifier = process.env.TRAVIS_JOB_NUMBER; +} + +var WOMBAT_JS_PATH = 'pywb/static/wombat.js'; + +var customLaunchers = { + sl_chrome: { + base: 'SauceLabs', + browserName: 'chrome', + }, + + sl_firefox: { + base: 'SauceLabs', + browserName: 'firefox', + }, + +/* Safari and Edge are currently broken in + pywb. + + See: https://github.com/ikreymer/pywb/issues/148 (Edge) + https://github.com/ikreymer/pywb/issues/147 (Safari) + + sl_safari: { + base: 'SauceLabs', + browserName: 'safari', + platform: 'OS X 10.11', + version: '9.0', + }, + sl_edge: { + base: 'SauceLabs', + browserName: 'MicrosoftEdge', + }, +*/ +}; + +module.exports = function(config) { + config.set({ + basePath: '../', + + frameworks: ['mocha', 'chai'], + + files: [ + { + pattern: WOMBAT_JS_PATH, + watched: true, + included: false, + served: true, + }, + 'karma-tests/*.spec.js', + ], + + preprocessors: {}, + + reporters: ['progress'], + + port: 9876, + + colors: true, + + logLevel: config.LOG_INFO, + + autoWatch: true, + + sauceLabs: sauceLabsConfig, + + // use an extended timeout for capturing Sauce Labs + // browsers in case the service is busy + captureTimeout: 3 * 60000, + + customLaunchers: customLaunchers, + + browsers: Object.keys(customLaunchers), + + singleRun: false, + + concurrency: Infinity + }) +}; diff --git a/karma-tests/wombat.spec.js b/karma-tests/wombat.spec.js new file mode 100644 index 00000000..7012da83 --- /dev/null +++ b/karma-tests/wombat.spec.js @@ -0,0 +1,148 @@ +var WOMBAT_SRC = '../pywb/static/wombat.js'; +var DEFAULT_TIMEOUT = 20000; + +// creates a new document in an