Wallabyjs - keep getting TypeError: 'undefined'
Wallabyjs - keep getting TypeError: 'undefined'
我正在尝试使用类似于 this example 的 wallaby 配置,但我不断收到以下错误:
TypeError: 'undefined' is not an object (evaluating
'window.__moduleBundler.loadTests')
我的小袋鼠:
var wallabyWebpack = require('wallaby-webpack');
module.exports = function (wallaby) {
var webpackPostprocessor = wallabyWebpack({
// webpack options
externals: {
// Use external version of React instead of rebuilding it
"react": "React"
},
resolve: {
extensions: ['', '.js', '.jsx']
}
});
return {
files: [
//not required if using PhantomJs2 - http://wallabyjs.com/docs/integration/phantomjs2.html
{pattern: 'node_modules/phantomjs-polyfill/bind-polyfill.js', instrument: false},
{pattern: 'node_modules/react/dist/react-with-addons.js', instrument: false},
{pattern: 'app/**/*.js*', load: false}
],
tests: [
{pattern: 'app/**/*.spec.js*', load: false}
],
compilers: {
'**/*.js*': wallaby.compilers.babel()
},
postprocessor: webpackPostprocessor,
bootstrap: function () {
window.__moduleBundler.loadTests();
},
debug: true
};
};
我的package.json
:
{
"name": "react-example",
"version": "0.0.0",
"description": "",
"scripts": {
"start": "web-build start",
"build": "web-build build",
"test": "web-build test",
"unit": "web-build unit",
"e2e": "wix-web-build e2e",
"release": ":"
},
"repository": {
"type": "git",
"url": "---"
},
"keywords": [
"react",
"example"
],
"author": "",
"license": "MIT",
"devDependencies": {
"babel-core": "^6.9.1",
"babel-preset-es2015": "^6.9.0",
"babel-preset-react": "^6.5.0",
"babel-preset-stage-0": "^6.5.0",
"expect": "^1.18.0",
"petri-specs": "^1.0.0",
"phantomjs-polyfill": "0.0.2",
"react-addons-test-utils": "^0.14.8",
"wallaby-webpack": "0.0.22"
},
"dependencies": {
"react": "^0.14.7",
"react-dom": "^0.14.7",
"react-redux": "^4.4.5",
"redux": "^3.5.2"
},
"private": true
}
我做错了什么??
回答我自己的问题:我使用 debug: true
调试我的代码,发现我没有安装 webpack。所以,npm install webpack --save-dev
解决了这个问题。
我正在尝试使用类似于 this example 的 wallaby 配置,但我不断收到以下错误:
TypeError: 'undefined' is not an object (evaluating 'window.__moduleBundler.loadTests')
我的小袋鼠:
var wallabyWebpack = require('wallaby-webpack');
module.exports = function (wallaby) {
var webpackPostprocessor = wallabyWebpack({
// webpack options
externals: {
// Use external version of React instead of rebuilding it
"react": "React"
},
resolve: {
extensions: ['', '.js', '.jsx']
}
});
return {
files: [
//not required if using PhantomJs2 - http://wallabyjs.com/docs/integration/phantomjs2.html
{pattern: 'node_modules/phantomjs-polyfill/bind-polyfill.js', instrument: false},
{pattern: 'node_modules/react/dist/react-with-addons.js', instrument: false},
{pattern: 'app/**/*.js*', load: false}
],
tests: [
{pattern: 'app/**/*.spec.js*', load: false}
],
compilers: {
'**/*.js*': wallaby.compilers.babel()
},
postprocessor: webpackPostprocessor,
bootstrap: function () {
window.__moduleBundler.loadTests();
},
debug: true
};
};
我的package.json
:
{
"name": "react-example",
"version": "0.0.0",
"description": "",
"scripts": {
"start": "web-build start",
"build": "web-build build",
"test": "web-build test",
"unit": "web-build unit",
"e2e": "wix-web-build e2e",
"release": ":"
},
"repository": {
"type": "git",
"url": "---"
},
"keywords": [
"react",
"example"
],
"author": "",
"license": "MIT",
"devDependencies": {
"babel-core": "^6.9.1",
"babel-preset-es2015": "^6.9.0",
"babel-preset-react": "^6.5.0",
"babel-preset-stage-0": "^6.5.0",
"expect": "^1.18.0",
"petri-specs": "^1.0.0",
"phantomjs-polyfill": "0.0.2",
"react-addons-test-utils": "^0.14.8",
"wallaby-webpack": "0.0.22"
},
"dependencies": {
"react": "^0.14.7",
"react-dom": "^0.14.7",
"react-redux": "^4.4.5",
"redux": "^3.5.2"
},
"private": true
}
我做错了什么??
回答我自己的问题:我使用 debug: true
调试我的代码,发现我没有安装 webpack。所以,npm install webpack --save-dev
解决了这个问题。