diff --git a/.gitignore b/.gitignore index 6e7925c..ad3ac3b 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,6 @@ typings/ typings.json node_modules/ dist/ +*.env +coverage/ +npm-debug.log diff --git a/.travis.yml b/.travis.yml index 2211ecf..595a08a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,4 @@ +sudo: false language: node_js node_js: - "5" @@ -6,10 +7,14 @@ node_js: - "8" - "node" -sudo: false +addons: + chrome: stable + firefox: latest + script: - npm test - npm run lint + - npm run browser-test git: depth: 1 diff --git a/ci/spec-bundle.js b/ci/spec-bundle.js new file mode 100644 index 0000000..ba4c31a --- /dev/null +++ b/ci/spec-bundle.js @@ -0,0 +1,7 @@ +var testContext = require.context("../src", true, /\.spec\.ts$/); + +function requireAll(context) { + return context.keys().map(context); +} + +var modules = requireAll(testContext); diff --git a/karma.conf.js b/karma.conf.js new file mode 100644 index 0000000..cba3215 --- /dev/null +++ b/karma.conf.js @@ -0,0 +1,54 @@ +module.exports = function(config) { + var configuration = { + frameworks: ["jasmine"], + files: [ + {pattern: './ci/spec-bundle.js', watched: false} + ], + preprocessors: { + './ci/spec-bundle.js': ['webpack', 'sourcemap'], + }, + webpackMiddleware: { + scripts: 'errors-only' + }, + webpack: { + devtool: "inline-source-map", + resolve: { + extensions: ['.ts', '.js'], + }, + module: { + rules: [ + { + test: /\.ts$/, + exclude: /node_modules/, + use: [{loader: 'ts-loader', options: {transpileOnly: true}}] + } + ] + }, + }, + mime: { + 'text/x-typescript': ['ts', 'tsx'] + }, + reporters: ["progress"], + browsers: ["ChromeHeadless", "FirefoxHeadless"], + customLaunchers: { + ChromeHeadlessTravis: { + base: "ChromeHeadless", + flags: ['--no-sandbox'] + } + }, + concurrency: 8, + plugins: [ + 'karma-jasmine', + 'karma-chrome-launcher', + 'karma-firefox-launcher', + 'karma-webpack', + 'karma-sourcemap-loader' + ] + }; + + if (process.env.TRAVIS) { + configuration.browsers = ['ChromeHeadlessTravis', 'FirefoxHeadless']; + } + + config.set(configuration); +} diff --git a/package.json b/package.json index fd92725..57c7313 100644 --- a/package.json +++ b/package.json @@ -13,11 +13,20 @@ "gulp-tslint": "^8.1.2", "gulp-typescript": "^3.2.3", "tslint": "^5.8.0", - "typescript": "^2.6.2" + "typescript": "^2.6.2", + "webpack": "^3.10.0", + "karma": "^2.0.0", + "karma-jasmine": "^1.1.1", + "karma-chrome-launcher": "^2.2.0", + "karma-firefox-launcher": "^1.1.0", + "karma-webpack": "^2.0.9", + "karma-sourcemap-loader": "^0.3.7", + "ts-loader": "^3.3.1" }, "scripts": { "test": "gulp test", - "lint": "gulp lint" + "lint": "gulp lint", + "browser-test": "karma start --single-run" }, "repository": { "type": "git",