build: adjust test build setup for easier requires

This commit is contained in:
Evan You 2015-12-26 20:02:57 -05:00
parent 599e38edb0
commit f7a91fc9f4
57 changed files with 132 additions and 125 deletions

View File

@ -1,3 +1,7 @@
var webpackConfig = require('./webpack.test.config')
delete webpackConfig.entry
delete webpackConfig.devtool
// shared config for all unit tests
module.exports = {
frameworks: ['jasmine'],
@ -8,17 +12,7 @@ module.exports = {
preprocessors: {
'../test/unit/specs/index.js': ['webpack']
},
webpack: {
module: {
loaders: [
{
test: /\.js$/,
exclude: /test|node_modules/,
loader: 'babel?optional[]=runtime&loose=all'
}
]
}
},
webpack: webpackConfig,
webpackMiddleware: {
noInfo: true
},

View File

@ -1,9 +1,10 @@
var path = require('path')
var webpack = require('webpack')
module.exports = {
entry: './src/index',
output: {
path: './dist',
path: path.resolve(__dirname, '../dist'),
filename: 'vue.js',
library: 'Vue',
libraryTarget: 'umd'

View File

@ -1,18 +1,29 @@
var path = require('path')
var webpack = require('webpack')
module.exports = {
entry: './test/unit/specs/index.js',
output: {
path: './test/unit',
path: path.resolve(__dirname, '../test/unit'),
filename: 'specs.js'
},
resolve: {
alias: {
src: path.resolve(__dirname, '../src')
}
},
module: {
loaders: [
{ test: /\.js$/, loader: 'babel', exclude: /test\/unit/ }
{
test: /\.js$/,
loader: 'babel',
exclude: /test\/unit|node_modules/
}
]
},
babel: {
loose: 'all'
loose: 'all',
optional: ['runtime']
},
plugins: [
new webpack.DefinePlugin({
@ -22,7 +33,8 @@ module.exports = {
})
],
devServer: {
contentBase: './test/unit'
contentBase: './test/unit',
noInfo: true
},
devtool: '#source-map'
}

View File

@ -1,5 +1,5 @@
var Vue = require('../../../../src/index')
var _ = require('../../../../src/util')
var Vue = require('src')
var _ = require('src/util')
var nextTick = _.nextTick
describe('Data API', function () {

View File

@ -3,8 +3,8 @@
* those are tested in transition_spec.js.
*/
var Vue = require('../../../../src/index')
var _ = require('../../../../src/util')
var Vue = require('src')
var _ = require('src/util')
describe('DOM API', function () {

View File

@ -1,4 +1,4 @@
var Vue = require('../../../../src/index')
var Vue = require('src')
describe('Events API', function () {

View File

@ -1,6 +1,6 @@
var Vue = require('../../../../src/index')
var _ = require('../../../../src/util')
var config = require('../../../../src/config')
var Vue = require('src')
var _ = require('src/util')
var config = require('src/config')
describe('Global API', function () {

View File

@ -1,5 +1,5 @@
var Vue = require('../../../../src/index')
var compiler = require('../../../../src/compiler')
var Vue = require('src')
var compiler = require('src/compiler')
describe('Lifecycle API', function () {

View File

@ -1,4 +1,4 @@
var Vue = require('../../../src/index')
var Vue = require('src')
var _ = Vue.util
describe('Async components', function () {

View File

@ -1,6 +1,6 @@
var config = require('../../../src/config')
var batcher = require('../../../src/batcher')
var nextTick = require('../../../src/util').nextTick
var config = require('src/config')
var batcher = require('src/batcher')
var nextTick = require('src/util').nextTick
describe('Batcher', function () {

View File

@ -1,4 +1,4 @@
var Cache = require('../../../src/cache')
var Cache = require('src/cache')
/**
* Debug function to assert cache state

View File

@ -1,9 +1,9 @@
var Vue = require('../../../../src/index')
var _ = require('../../../../src/util')
var compiler = require('../../../../src/compiler')
var Vue = require('src')
var _ = require('src/util')
var compiler = require('src/compiler')
var compile = compiler.compile
var publicDirectives = require('../../../../src/directives/public')
var internalDirectives = require('../../../../src/directives/internal')
var publicDirectives = require('src/directives/public')
var internalDirectives = require('src/directives/internal')
describe('Compile', function () {

View File

@ -1,6 +1,6 @@
var transclude = require('../../../../src/compiler').transclude
var Vue = require('../../../../src/index')
var _ = require('../../../../src/util')
var transclude = require('src/compiler').transclude
var Vue = require('src')
var _ = require('src/util')
describe('Transclude', function () {

View File

@ -1,5 +1,5 @@
var Vue = require('../../../src/index')
var Directive = require('../../../src/directive')
var Vue = require('src')
var Directive = require('src/directive')
var nextTick = Vue.nextTick
describe('Directive', function () {

View File

@ -1,6 +1,6 @@
var Vue = require('../../../../../src/index')
var _ = require('../../../../../src/util')
var compiler = require('../../../../../src/compiler')
var Vue = require('src')
var _ = require('src/util')
var compiler = require('src/compiler')
describe('Partial', function () {

View File

@ -1,5 +1,5 @@
var Vue = require('../../../../../src/index')
var _ = require('../../../../../src/util')
var Vue = require('src')
var _ = require('src/util')
describe('Slot Distribution', function () {

View File

@ -1,5 +1,5 @@
var _ = require('../../../../../src/util')
var def = require('../../../../../src/directives/internal/class')
var _ = require('src/util')
var def = require('src/directives/internal/class')
describe(':class', function () {

View File

@ -1,5 +1,5 @@
var _ = require('../../../../../src/util')
var Vue = require('../../../../../src/index')
var _ = require('src/util')
var Vue = require('src')
describe('Component', function () {

View File

@ -1,4 +1,4 @@
var Vue = require('../../../../../src/index')
var Vue = require('src')
describe('prop', function () {

View File

@ -1,6 +1,6 @@
var _ = require('../../../../../src/util')
var def = require('../../../../../src/directives/internal/style')
var Vue = require('../../../../../src/index')
var _ = require('src/util')
var def = require('src/directives/internal/style')
var Vue = require('src')
function checkPrefixedProp (prop) {
var el = document.createElement('div')

View File

@ -1,7 +1,7 @@
var _ = require('../../../../../src/util')
var Vue = require('../../../../../src/index')
var Directive = require('../../../../../src/directive')
var def = require('../../../../../src/directives/internal/transition')
var _ = require('src/util')
var Vue = require('src')
var Directive = require('src/directive')
var def = require('src/directives/internal/transition')
describe('transition', function () {

View File

@ -1,5 +1,5 @@
var _ = require('../../../../../src/util')
var def = require('../../../../../src/directives/public/bind')
var _ = require('src/util')
var def = require('src/directives/public/bind')
var xlinkNS = 'http://www.w3.org/1999/xlink'
describe('v-bind', function () {

View File

@ -1,5 +1,5 @@
var compile = require('../../../../../src/compiler').compile
var Vue = require('../../../../../src/index')
var compile = require('src/compiler').compile
var Vue = require('src')
describe('v-cloak', function () {

View File

@ -1,5 +1,5 @@
var _ = require('../../../../../src/util')
var Vue = require('../../../../../src/index')
var _ = require('src/util')
var Vue = require('src')
describe('el', function () {

View File

@ -1,4 +1,4 @@
var Vue = require('../../../../../../src/index')
var Vue = require('src')
var _ = Vue.util
describe('v-for + ref', function () {

View File

@ -1,6 +1,6 @@
var _ = require('../../../../../../src/util')
var Vue = require('../../../../../../src/index')
var config = require('../../../../../../src/config')
var _ = require('src/util')
var Vue = require('src')
var config = require('src/config')
describe('v-for', function () {

View File

@ -1,4 +1,4 @@
var Vue = require('../../../../../../src/index')
var Vue = require('src')
var _ = Vue.util
describe('v-for staggering transitions', function () {

View File

@ -1,5 +1,5 @@
var _ = require('../../../../../src/util')
var def = require('../../../../../src/directives/public/html')
var _ = require('src/util')
var def = require('src/directives/public/html')
describe('v-html', function () {

View File

@ -1,5 +1,5 @@
var _ = require('../../../../../src/util')
var Vue = require('../../../../../src/index')
var _ = require('src/util')
var Vue = require('src')
describe('v-if', function () {

View File

@ -1,5 +1,5 @@
var _ = require('../../../../../src/util')
var Vue = require('../../../../../src/index')
var _ = require('src/util')
var Vue = require('src')
// unset jQuery to bypass jQuery check for normal test cases
jQuery = null

View File

@ -1,5 +1,5 @@
var _ = require('../../../../../src/util')
var Vue = require('../../../../../src/index')
var _ = require('src/util')
var Vue = require('src')
function trigger (target, event, process) {
var e = document.createEvent('HTMLEvents')

View File

@ -1,4 +1,4 @@
var Vue = require('../../../../../src/index')
var Vue = require('src')
describe('v-pre', function () {

View File

@ -1,5 +1,5 @@
var _ = require('../../../../../src/util')
var Vue = require('../../../../../src/index')
var _ = require('src/util')
var Vue = require('src')
describe('ref', function () {

View File

@ -1,6 +1,6 @@
var Vue = require('../../../../../src/index')
var transition = require('../../../../../src/transition')
var def = require('../../../../../src/directives/public/show')
var Vue = require('src')
var transition = require('src/transition')
var def = require('src/directives/public/show')
describe('v-show', function () {

View File

@ -1,5 +1,5 @@
var _ = require('../../../../../src/util')
var def = require('../../../../../src/directives/public/text')
var _ = require('src/util')
var def = require('src/directives/public/text')
describe('v-text', function () {

View File

@ -1,4 +1,4 @@
var filters = require('../../../../src/filters')
var filters = require('src/filters')
describe('Filters', function () {

View File

@ -1,5 +1,5 @@
// set some global Vue options
var Vue = require('../../../src/index')
var Vue = require('src')
Vue.options.replace = false
Vue.config.silent = true
@ -10,8 +10,8 @@ Vue.config.silent = true
* utility functions.
*/
var _ = require('../../../src/util')
var __ = require('../../../src/util/debug')
var _ = require('src/util')
var __ = require('src/util/debug')
var scope = typeof window === 'undefined'
? global
: window

View File

@ -1,5 +1,5 @@
var Vue = require('../../../../src/index')
var _ = require('../../../../src/util')
var Vue = require('src')
var _ = require('src/util')
describe('Instance Events', function () {

View File

@ -1,4 +1,4 @@
var Vue = require('../../../../src/index')
var Vue = require('src')
var init = Vue.prototype._init
describe('Instance Init', function () {

View File

@ -1,4 +1,4 @@
var Vue = require('../../../../src/index')
var Vue = require('src')
describe('misc', function () {

View File

@ -1,5 +1,5 @@
var Vue = require('../../../../src/index')
var _ = require('../../../../src/util')
var Vue = require('src')
var _ = require('src/util')
describe('Instance state initialization', function () {

View File

@ -1,5 +1,5 @@
// test cases for edge cases & bug fixes
var Vue = require('../../../src/index')
var Vue = require('src')
var _ = Vue.util
describe('Misc', function () {

View File

@ -1,4 +1,4 @@
var Dep = require('../../../../src/observer/dep')
var Dep = require('src/observer/dep')
describe('Dep', function () {

View File

@ -1,10 +1,10 @@
var Vue = require('../../../../src')
var ob = require('../../../../src/observer')
var Vue = require('src')
var ob = require('src/observer')
var Observer = ob.Observer
var observe = ob.observe
var Dep = require('../../../../src/observer/dep')
var _ = require('../../../../src/util')
var config = require('../../../../src/config')
var Dep = require('src/observer/dep')
var _ = require('src/util')
var config = require('src/config')
describe('Observer', function () {

View File

@ -1,4 +1,4 @@
var parse = require('../../../../src/parsers/directive').parseDirective
var parse = require('src/parsers/directive').parseDirective
describe('Directive Parser', function () {

View File

@ -1,4 +1,4 @@
var expParser = require('../../../../src/parsers/expression')
var expParser = require('src/parsers/expression')
var testCases = [
{

View File

@ -1,5 +1,5 @@
var Path = require('../../../../src/parsers/path')
var _ = require('../../../../src/util')
var Path = require('src/parsers/path')
var _ = require('src/util')
function assertPath (str, expected) {
var path = Path.parsePath(str)

View File

@ -1,4 +1,4 @@
var templateParser = require('../../../../src/parsers/template')
var templateParser = require('src/parsers/template')
var parse = templateParser.parseTemplate
var testString = '<div>hello</div><p class="test">world</p>'

View File

@ -1,6 +1,6 @@
var textParser = require('../../../../src/parsers/text')
var dirParser = require('../../../../src/parsers/directive')
var config = require('../../../../src/config')
var textParser = require('src/parsers/text')
var dirParser = require('src/parsers/directive')
var config = require('src/config')
var testCases = [
{

View File

@ -1,7 +1,7 @@
var Vue = require('../../../../src/index')
var _ = require('../../../../src/util')
var transition = require('../../../../src/transition')
var Transition = require('../../../../src/transition/transition')
var Vue = require('src')
var _ = require('src/util')
var transition = require('src/transition')
var Transition = require('src/transition/transition')
if (!_.isIE9) {
describe('Transition', function () {

View File

@ -1,4 +1,4 @@
var _ = require('../../../../src/util')
var _ = require('src/util')
describe('Util - component', function () {

View File

@ -1,5 +1,5 @@
var _ = require('../../../../src/util')
var config = require('../../../../src/config')
var _ = require('src/util')
var config = require('src/config')
var warnPrefix = '[Vue warn]: '
if (typeof console !== 'undefined') {

View File

@ -1,4 +1,4 @@
var _ = require('../../../../src/util')
var _ = require('src/util')
describe('Util - DOM', function () {

View File

@ -1,4 +1,4 @@
var _ = require('../../../../src/util')
var _ = require('src/util')
describe('Util - Environment', function () {

View File

@ -1,4 +1,4 @@
var _ = require('../../../../src/util')
var _ = require('src/util')
describe('Util - Language Enhancement', function () {

View File

@ -1,5 +1,5 @@
var _ = require('../../../../src/util')
var Vue = require('../../../../src/index')
var _ = require('src/util')
var Vue = require('src')
var merge = _.mergeOptions
var resolveAsset = _.resolveAsset
@ -263,7 +263,7 @@ describe('Util - Option merging', function () {
})
it('already observed instance data merge with default data', function () {
var observe = require('../../../../src/observer').observe
var observe = require('src/observer').observe
var instanceData = { a: 123 }
// observe it
observe(instanceData)

View File

@ -1,6 +1,6 @@
var Vue = require('../../../src/index')
var Vue = require('src')
var nextTick = Vue.nextTick
var Watcher = require('../../../src/watcher')
var Watcher = require('src/watcher')
var _ = Vue.util
var config = Vue.config