为什么我得到&base/src/tests/core/types.tests!'没有时间戳?

时间:2014-05-17 01:07:57

标签: 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

以下是我正在使用的目录结构。

.
|-- 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

以下是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
    });
};

最后这是我的'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
});

1 个答案:

答案 0 :(得分:9)

我花了几天时间弄明白,在我的Karma配置文件和requirejs' tests.main.js'中,路径都是不正确的。文件。

所以我做的是去Karma - RequireJS教程,从github下载project并基本上一点一点地进行重组,以了解它为什么不在我自己的项目中工作。

我有两个重复出现的错误,两者都与错误的路径有关,所以我在另一个问题中发布了full solution我在StackOverflow上提出的问题。

此解决方案现已在GitHub处提供。