This commit is contained in:
Petyo Ivanov 2016-04-13 18:45:08 +03:00
Родитель e07bf57126
Коммит 0605a37fc8
6 изменённых файлов: 85 добавлений и 2 удалений

5
e2e-bundle.js Normal file
Просмотреть файл

@ -0,0 +1,5 @@
Error.stackTraceLimit = Infinity;
const e2eContext = require.context('./e2e', true, /(.*)\.js$/);
e2eContext.keys().forEach(e2eContext);

30
e2e-utils.js Normal file
Просмотреть файл

@ -0,0 +1,30 @@
/*eslint no-var: 0 */
var $ = require('jquery');
var chai = require('chai');
var chaiJquery = require('chai-jquery');
var expect = chai.expect;
global.jQuery = $;
chai.should();
chai.use(chaiJquery);
function withRoot(closure) {
return function() {
var root = $("<div />").appendTo(document.body);
afterEach(function() {
root.empty();
});
closure(root);
};
}
module.exports = {
"$": $,
"expect": expect,
"withRoot": withRoot
};

4
e2e.conf.js Normal file
Просмотреть файл

@ -0,0 +1,4 @@
const commonTasks = require('@telerik/kendo-common-tasks');
module.exports = (config) =>
commonTasks.karmaConfig(config, require('./webpack.config.js').e2e, 'e2e-bundle.js');

Просмотреть файл

@ -1,3 +1,4 @@
const path = require('path');
const jasmine = require('gulp-jasmine');
const specReporter = require('jasmine-spec-reporter');
const webpackConfig = require('./webpack.config.js');
@ -7,6 +8,7 @@ const SRC = "src/*.js";
const TESTS = "test/**/*.js";
const SRC_TESTS = [ SRC, TESTS ];
const DTS = "src/*.d.ts";
const e2eConfigPath = path.join(__dirname, 'e2e.conf.js');
module.exports = function(gulp, libraryName) {
commonTasks.addTasks(gulp, libraryName, SRC, webpackConfig, DTS);
@ -24,4 +26,10 @@ module.exports = function(gulp, libraryName) {
gulp.run('test');
return gulp.watch(SRC_TESTS, [ 'test' ]);
});
gulp.task('e2e', (done) =>
commonTasks.startKarma(done, e2eConfigPath, true));
gulp.task('watch-e2e', (done) =>
commonTasks.startKarma(done, e2eConfigPath, false));
};

Просмотреть файл

@ -25,7 +25,11 @@
"babel-traverse": "6.3.19",
"gulp-jasmine": "^2.2.1",
"jasmine-reporters": "^2.1.1",
"jasmine-spec-reporter": "^2.4.0"
"jasmine-spec-reporter": "^2.4.0",
"chai": "^3.5.0",
"chai-jquery": "^2.0.0",
"jquery": "^2.2.1",
"source-map-loader": "^0.1.5"
},
"author": "Telerik",
"license": "Apache-2.0",

Просмотреть файл

@ -6,6 +6,8 @@ const nodeModulesPath = path.join(__dirname, 'node_modules');
const resolve = commonTasks.resolveConfig(sourceExtensions, nodeModulesPath);
const packageInfo = require(path.join(process.cwd(), 'package.json'));
const babelLoader = {
test: /\.js?$/,
exclude: /(node_modules|bower_components)/,
@ -58,6 +60,36 @@ module.exports = {
babelLoader
]
}
} // test
}, // test
e2e: {
resolve: {
cache: false,
fallback: resolve.fallback,
alias: {
"./e2e": process.cwd() + "/e2e",
"e2e-utils": require.resolve("./e2e-utils.js"),
[packageInfo.name]: '../src/main'
},
extensions: [ '', '.js' ]
},
devtool: 'inline-source-map',
module: {
preLoaders: [
{
test: /\.js$/,
loader: require.resolve("source-map-loader")
}
],
loaders: [
babelLoader
]
},
stats: { colors: true, reasons: true },
debug: false,
plugins: [
new commonTasks.webpack.ContextReplacementPlugin(/\.\/e2e/, process.cwd() + '/e2e')
]
}
}; // module.exports