Eya*_*nik 5 javascript requirejs karma-runner
我想弄清楚几个小时,我想这与我配置错误的requirejs文件('test.main.js')有关,但我不太确定,有人可以向我解释有什么问题吗?
如果您需要我提供更多信息,我很乐意提供.
这是堆栈跟踪的输出.
Eyal Shilony@LIONKING /d/Projects/Code/Development/tsToolkit
$ ./karma.sh start
INFO [karma]: Karma v0.12.16 server started at http://localhost:8380/
INFO [IE 11.0.0 (Windows 7)]: Connected on socket GCSNAkUAY24F-MN7dkGQ with id manual-4464
IE 11.0.0 (Windows 7) ERROR: 'There is no timestamp for /base/src/tests/core/types.tests!'
WARN [web-server]: 404: /base/src/tests/core/types.tests
IE 11.0.0 (Windows 7) ERROR
Script error for: /base/src/tests/core/types.tests
http://requirejs.org/docs/errors.html#scripterror
at D:/Projects/Code/Development/tsToolkit/node_modules/requirejs/require.js:141
Run Code Online (Sandbox Code Playgroud)
这是我正在使用atm的目录结构.
.
|-- WebEssentials-Settings.json
|-- jake.sh
|-- jakefile.js
|-- karma.sh
|-- node_modules
| |-- jake
| | |-- Jakefile
| | |-- Makefile
| | |-- README.md
| | |-- bin
| | |-- lib
| | |-- node_modules
| | |-- package.json
| | `-- test
| |-- jasmine-node
| | |-- Gruntfile.coffee
| | |-- LICENSE
| | |-- README.md
| | |-- bin
| | |-- bower.json
| | |-- index.js
| | |-- lib
| | |-- node_modules
| | |-- package.json
| | |-- scripts
| | |-- spec
| | `-- src
| |-- karma
| | |-- CHANGELOG.md
| | |-- LICENSE
| | |-- README.md
| | |-- bin
| | |-- config.tpl.coffee
| | |-- config.tpl.js
| | |-- config.tpl.ls
| | |-- karma-completion.sh
| | |-- lib
| | |-- node_modules
| | |-- package.json
| | |-- requirejs.config.tpl.coffee
| | |-- requirejs.config.tpl.js
| | `-- static
| |-- karma-jasmine
| | |-- LICENSE
| | |-- README.md
| | |-- lib
| | `-- package.json
| |-- karma-requirejs
| | |-- LICENSE
| | |-- README.md
| | |-- lib
| | `-- package.json
| |-- karma-requirejs-preprocessor
| | `-- index.js
| |-- requirejs
| | |-- README.md
| | |-- bin
| | |-- package.json
| | `-- require.js
| `-- shelljs
| |-- LICENSE
| |-- README.md
| |-- bin
| |-- global.js
| |-- make.js
| |-- package.json
| |-- scripts
| |-- shell.js
| `-- src
|-- scratchpad.txt
|-- src
| |-- app.main.js
| |-- app.main.js.map
| |-- app.main.ts
| |-- framework
| | |-- core
| | |-- css
| | `-- widgets
| |-- index.html
| |-- libs
| | |-- jquery-2.1.0.js
| | |-- require.js
| | `-- typings
| |-- tests
| | |-- core
| | `-- test.main.js
| |-- tsToolkit.csproj
| |-- tsToolkit.csproj.user
| |-- web.Debug.config
| |-- web.Release.config
| `-- web.config
|-- tools
| |-- karma
| | |-- karma.conf.js
| | `-- karma.conf.js.back
| `-- mocha
| `-- mocha.ext.js
|-- tsToolkit.sln
|-- tsToolkit.sln.DotSettings.user
`-- tsToolkit.v12.suo
41 directories, 59 files
Run Code Online (Sandbox Code Playgroud)
这是Karma的配置文件.
// Karma configuration
// Generated on Fri May 16 2014 08:27:07 GMT+0300 (Jerusalem Daylight Time)
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: ['jasmine', 'requirejs'],
// list of files / patterns to load in the browser
files: [
{pattern: 'src/libs/*.js', included: false},
{pattern: 'src/framework/**/*.js', included: false},
{pattern: 'src/tests/**/*tests.js', included: false},
'src/tests/test.main.js'
],
// list of files to exclude
exclude: [
'src/app.main.js'
],
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
},
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['progress'],
// web server port
port: 8380,
// 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: [],
// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: false
});
};
Run Code Online (Sandbox Code Playgroud)
最后这里是我的'test.main.js'文件,为Karma设置requirejs.
var tests = [];
for (var file in window.__karma__.files) {
if (window.__karma__.files.hasOwnProperty(file)) {
if (/\.tests\.js$/.test(file)) {
tests.push(file.replace(/\.js$/, ""));
}
}
}
requirejs.config({
baseUrl: '/base',
deps: tests,
callback: window.__karma__.start
});
Run Code Online (Sandbox Code Playgroud)
我花了几天时间弄明白,我的Karma配置文件和requirejs'tests.main.js'文件中的路径都是不正确的.
所以我做的是去Karma - RequireJS教程,从github 下载项目并基本上一点一点地重组它以理解为什么它在我自己的项目中不起作用.
我有两个重复出现的错误,它们都与错误的路径有关,所以我在StackOverflow上提出的另一个问题中发布了完整的解决方案.
该解决方案现在可在GitHub上获得.
| 归档时间: |
|
| 查看次数: |
9729 次 |
| 最近记录: |