Evan You
9 years ago
12 changed files with 277 additions and 30 deletions
@ -0,0 +1,42 @@ |
|||
var alias = require('./alias') |
|||
var webpack = require('webpack') |
|||
|
|||
var webpackConfig = { |
|||
resolve: { |
|||
alias: Object.assign({}, alias, { |
|||
entities: './entity-decoder' |
|||
}) |
|||
}, |
|||
module: { |
|||
loaders: [ |
|||
{ |
|||
test: /\.js$/, |
|||
loader: 'babel', |
|||
exclude: /node_modules/ |
|||
} |
|||
] |
|||
}, |
|||
plugins: [ |
|||
new webpack.DefinePlugin({ |
|||
'process.env': { |
|||
NODE_ENV: '"development"' |
|||
} |
|||
}) |
|||
], |
|||
devtool: '#inline-source-map' |
|||
} |
|||
|
|||
// shared config for all unit tests
|
|||
module.exports = { |
|||
frameworks: ['jasmine'], |
|||
files: [ |
|||
'../test/unit/index.js' |
|||
], |
|||
preprocessors: { |
|||
'../test/unit/index.js': ['webpack', 'sourcemap'] |
|||
}, |
|||
webpack: webpackConfig, |
|||
webpackMiddleware: { |
|||
noInfo: true |
|||
} |
|||
} |
@ -0,0 +1,27 @@ |
|||
var path = require('path') |
|||
var base = require('./karma.base.config.js') |
|||
|
|||
module.exports = function (config) { |
|||
var options = Object.assign(base, { |
|||
browsers: ['PhantomJS'], |
|||
reporters: ['progress', 'coverage'], |
|||
coverageReporter: { |
|||
reporters: [ |
|||
{ type: 'lcov', dir: '../coverage', subdir: '.' }, |
|||
{ type: 'text-summary', dir: '../coverage', subdir: '.' } |
|||
] |
|||
}, |
|||
singleRun: true |
|||
}) |
|||
|
|||
// add coverage loader
|
|||
options.webpack.module.preLoaders = [ |
|||
{ |
|||
test: /\.js$/, |
|||
include: path.resolve(__dirname, '../src'), |
|||
loader: 'isparta' |
|||
} |
|||
] |
|||
|
|||
config.set(options) |
|||
} |
@ -0,0 +1,8 @@ |
|||
var base = require('./karma.base.config.js') |
|||
|
|||
module.exports = function (config) { |
|||
config.set(Object.assign(base, { |
|||
browsers: ['Chrome'], |
|||
reporters: ['progress'] |
|||
})) |
|||
} |
@ -0,0 +1,81 @@ |
|||
var base = require('./karma.base.config.js') |
|||
|
|||
/** |
|||
* Having too many tests running concurrently on saucelabs |
|||
* causes timeouts and errors, so we have to run them in |
|||
* smaller batches. |
|||
*/ |
|||
|
|||
var batches = [ |
|||
// the cool kids
|
|||
{ |
|||
sl_chrome: { |
|||
base: 'SauceLabs', |
|||
browserName: 'chrome', |
|||
platform: 'Windows 7' |
|||
}, |
|||
sl_firefox: { |
|||
base: 'SauceLabs', |
|||
browserName: 'firefox' |
|||
}, |
|||
sl_mac_safari: { |
|||
base: 'SauceLabs', |
|||
browserName: 'safari', |
|||
platform: 'OS X 10.10' |
|||
} |
|||
}, |
|||
// ie family
|
|||
{ |
|||
sl_ie_9: { |
|||
base: 'SauceLabs', |
|||
browserName: 'internet explorer', |
|||
platform: 'Windows 7', |
|||
version: '9' |
|||
}, |
|||
sl_ie_10: { |
|||
base: 'SauceLabs', |
|||
browserName: 'internet explorer', |
|||
platform: 'Windows 8', |
|||
version: '10' |
|||
}, |
|||
sl_ie_11: { |
|||
base: 'SauceLabs', |
|||
browserName: 'internet explorer', |
|||
platform: 'Windows 8.1', |
|||
version: '11' |
|||
} |
|||
}, |
|||
// mobile
|
|||
{ |
|||
sl_ios_safari: { |
|||
base: 'SauceLabs', |
|||
browserName: 'iphone', |
|||
platform: 'OS X 10.9', |
|||
version: '7.1' |
|||
}, |
|||
sl_android: { |
|||
base: 'SauceLabs', |
|||
browserName: 'android', |
|||
platform: 'Linux', |
|||
version: '4.2' |
|||
} |
|||
} |
|||
] |
|||
|
|||
module.exports = function (config) { |
|||
var batch = batches[process.argv[4] || 0] |
|||
|
|||
config.set(Object.assign(base, { |
|||
browsers: Object.keys(batch), |
|||
customLaunchers: batch, |
|||
reporters: ['progress', 'saucelabs'], |
|||
sauceLabs: { |
|||
testName: 'Vue.js unit tests', |
|||
recordScreenshots: false, |
|||
build: process.env.CIRCLE_BUILD_NUM || process.env.SAUCE_BUILD_ID || Date.now() |
|||
}, |
|||
// mobile emulators are really slow
|
|||
captureTimeout: 300000, |
|||
browserNoActivityTimeout: 300000 |
|||
})) |
|||
} |
@ -0,0 +1,9 @@ |
|||
var base = require('./karma.base.config.js') |
|||
|
|||
module.exports = function (config) { |
|||
config.set(Object.assign(base, { |
|||
browsers: ['Chrome', 'Firefox', 'Safari'], |
|||
reporters: ['progress'], |
|||
singleRun: true |
|||
})) |
|||
} |
@ -0,0 +1,47 @@ |
|||
if (typeof console === 'undefined') { |
|||
window.console = { |
|||
error: function () {} |
|||
} |
|||
} |
|||
|
|||
function hasWarned (msg) { |
|||
var count = console.error.calls.count() |
|||
var args |
|||
while (count--) { |
|||
args = console.error.calls.argsFor(count) |
|||
if (args.some(containsMsg)) { |
|||
return true |
|||
} |
|||
} |
|||
|
|||
function containsMsg (arg) { |
|||
if (arg instanceof Error) throw arg |
|||
return typeof arg === 'string' && arg.indexOf(msg) > -1 |
|||
} |
|||
} |
|||
|
|||
// define custom matcher for warnings
|
|||
beforeEach(function () { |
|||
spyOn(console, 'error') |
|||
jasmine.addMatchers({ |
|||
toHaveBeenWarned: function () { |
|||
return { |
|||
compare: function (msg) { |
|||
var warned = Array.isArray(msg) |
|||
? msg.some(hasWarned) |
|||
: hasWarned(msg) |
|||
return { |
|||
pass: warned, |
|||
message: warned |
|||
? 'Expected message "' + msg + '" not to have been warned' |
|||
: 'Expected message "' + msg + '" to have been warned' |
|||
} |
|||
} |
|||
} |
|||
} |
|||
}) |
|||
}) |
|||
|
|||
// require all test files
|
|||
var testsContext = require.context('./specs', true, /\.spec$/) |
|||
testsContext.keys().forEach(testsContext) |
@ -0,0 +1,7 @@ |
|||
import Vue from 'vue' |
|||
|
|||
describe('test', function () { |
|||
it('should pass', function () { |
|||
expect(Vue.config.replace).toBeUndefined() |
|||
}) |
|||
}) |
Loading…
Reference in new issue