forked from xolvio/qualityfaster
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wallaby_client.js
101 lines (80 loc) · 2.78 KB
/
wallaby_client.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
var _ = require('underscore');
var path = require('path');
var fs = require('fs');
var wallabyWebpack = require('wallaby-webpack');
var babel = require('babel-core');
module.exports = function (wallaby) {
var webpackConfig = {
resolve: {
root: path.join(wallaby.projectCacheDir, 'src', 'imports'),
extensions: ['', '.js', '.jsx', '.json']
},
module: {
loaders: [
// JavaScript is handled by the Wallaby Babel compiler
{ test: /\.json$/, loader: 'json-loader' }
]
}
};
var wallabyPostprocessor = wallabyWebpack(webpackConfig);
var babelCompiler = wallaby.compilers.babel({
babel: babel,
presets: ['react', 'es2015', 'stage-0'],
plugins: ['transform-decorators-legacy'],
});
var packageStubs = fs.readdirSync('./src/imports/testing/client/stubs')
.map(function (fileName) {
return 'packages/' + fileName;
});
var appManifest = require(path.resolve('./src/.meteor/local/build/programs/web.browser/program.json')).manifest;
var meteorPackageFiles = appManifest
.filter(function (file) {
return file.type === 'js' && file.path.startsWith('packages/') &&
[
].indexOf(file.path) === -1;
})
.map(function (file) {
var basePath = packageStubs.indexOf(file.path) !== -1 ?
'tests/client/stubs' :
'src/.meteor/local/build/programs/web.browser';
return {pattern: path.join(basePath, file.path)};
});
return {
// set `load: false` to all source files and tests processed by webpack
// (except external files),
// as they should not be loaded in browser,
// their wrapped versions will be loaded instead
files: [
'src/.meteor/local/build/programs/web.browser/merged-stylesheets.css',
'src/imports/testing/client/__meteor_runtime_config__.js',
].concat(
meteorPackageFiles,
[
{pattern: 'src/imports/testing/_support/**', load: false},
{pattern: 'src/imports/**/*.@(js|jsx)', load: false},
{pattern: 'src/imports/**/*-spec.@(js|jsx)', ignore: true},
{pattern: 'src/imports/**/server/**/*.@(js|jsx)', ignore: true},
]
),
tests: [
{pattern: 'src/imports/**/*-spec.@(js|jsx)', load: false},
{pattern: 'src/imports/**/server/**/*-spec.@(js|jsx)', ignore: true},
],
compilers: {
// Important: Make sure that src/.meteor/ is excluded from the pattern
'src/imports/**/*.@(js|jsx)': babelCompiler,
'tests/**/*.@(js|jsx)': babelCompiler,
},
postprocessor: wallabyPostprocessor,
bootstrap: function () {
// required to trigger test loading
window.__moduleBundler.loadTests();
},
env: {
type: 'browser',
runner: require('phantomjs').path,
},
testFramework: 'jasmine',
debug: true,
};
};