如何将requirejs与QUnit一起使用



目前我有这个,取自一篇博客文章和主应用程序的原始requirejs主脚本:

require.config({
    baseUrl: 'js',
    paths: {
        domReady:       'lib/domReady',
        jquery:         'lib/jquery-1.10.2',
        bootstrap:      'lib/bootstrap',
        backbone:       'lib/backbone',
        underscore:     'lib/underscore',
        text:           'lib/text',
        raphael:        'lib/raphael',
        raphaelPlugins: 'lib/raphael.plugins',
        paper:          'lib/paper-full',
        kinetic:        'lib/kinetic-v4.6.0',
        fabric:         'lib/fabric'
    },
    shim: {
        'jquery': {
            exports: '$'
        },
        'bootstrap': {
            deps: ['jquery']
        },
        'backbone': {
            deps: ['underscore', 'jquery'],
            exports: 'Backbone'
        },
        'underscore': {
            exports: '_'
        },
        'fabric': {
            exports: 'fabric'
        },
        'raphaelPlugins': {
            deps: ['raphael']
        },
        'router': {
            deps: ['jquery', 'underscore', 'backbone', 'bootstrap', 'text']
        }
    }
});
require([
    'tests/core.test',
    'tests/models/header.test'
], function () {
    QUnit.start();
});

问题是它只运行传递给它的数组中的第一个测试。我怎样才能改变它,以便它运行它们?

此外,如何让它为每个单独的测试加载"路由器"的所有依赖项?

要加载路由器依赖项,请将路由器作为依赖项添加到测试文件中

我认为第二个文件中的所有测试都应该自动运行。 如果没有,则可能会阻止测试。 是否有任何异步测试?

我有一个旧博客,其中包含一些有关 qunit 的代码,需要 js 可能会有所帮助。 http://naheece.wordpress.com/2012/12/15/qunit-acceptance-test-framework-with-iframe-require-js-and-jquery-simulate/

最新更新