我正在尝试让JSPM / Karma / Babel / Jasmine一起工作。但是我在运行业力开始时遇到错误
15 04 2016 17:34:02.428:INFO [karma]: Karma v0.13.22 server started at http://localhost:9876/
15 04 2016 17:34:02.434:INFO [launcher]: Starting browser Chrome
15 04 2016 17:34:03.353:INFO [Chrome 49.0.2623 (Mac OS X 10.11.3)]: Connected on socket /#BSCbuviA4_LADHmaAAAA with id 80043999
15 04 2016 17:34:04.212:WARN [web-server]: 404: /base/aurelia-dependency-injection.js
15 04 2016 17:34:04.213:WARN [web-server]: 404: /base/aurelia-router.js
Chrome 49.0.2623 (Mac OS X 10.11.3) ERROR
Error: Error: XHR error (404 Not Found) loading /Users/allen/dev/work/Web/aurelia-dependency-injection.js
Error loading /Users/allen/dev/work/Web/wwwroot/src/app.js
我的文件夹结构:
> Web
karma.conf.js
-> node_modules
-> test
--> unit
-> wwwroot
--> src (all my js)
--> jspm_packages
config.js
我的Karam.conf.js:
module.exports = function(config) {
config.set({
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '',
// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['jspm', 'jasmine'],
jspm: {
// Edit this to your needs
loadFiles: ['test/unit/setup.js', 'test/unit/**/*.js'],
serveFiles: ['wwwroot/src/**/*.js'],
paths: {
'*': '*',
'github:*': 'jspm_packages/github/*',
'npm:*': 'jspm_packages/npm/*',
},
},
// list of files / patterns to load in the browser
files: [],
proxies: {
'/base/jspm_packages/': '/base/wwwroot/jspm_packages/',
},
// list of files to exclude
exclude: [],
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
'test/**/*.js': ['babel'],
'src/**/*.js': ['babel'],
},
babelPreprocessor: {
options: {
sourceMap: 'inline',
presets: ['es2015-loose', 'stage-1'],
plugins: [
'syntax-flow',
'transform-decorators-legacy',
'transform-flow-strip-types',
],
},
},
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['progress'],
// web server port
port: 9876,
// enable / disable colors in the output (reporters and logs)
colors: true,
// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,
// enable / disable watching file and executing tests whenever any file changes
autoWatch: true,
// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: ['Chrome'],
// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: false,
});
};
我的app.js有这些导入:
import { inject } from 'aurelia-dependency-injection';
import { Router } from 'aurelia-router';
import { Navscroll } from '../src/modules/scroll-anim.js'
我不确定我的代理是否设置正确或问题是什么?
答案 0 :(得分:0)
Error: Error: XHR error (404 Not Found) loading /Users/allen/dev/work/Web/aurelia-dependency-injection.js
Error loading /Users/allen/dev/work/Web/wwwroot/src/app.js
这是你的第一个问题。它不是代理的XHRing。相反,它试图使用路径网址。这肯定会失败,因为XHR只能做我所见过的HTTP。您需要protocol:// host:port / path format。
尝试转到http://localhost:9876/src/app.js
并查看浏览器中显示的内容。 (可能不需要包括/src/
app.js
可以从root用户提供。)
您必须在某处错误地加载app.js
文件。请包含您加载的地点app.js
。