Node.js 配置grunt watch以使用requirejs对应用程序运行Jasmine测试

Node.js 配置grunt watch以使用requirejs对应用程序运行Jasmine测试,node.js,requirejs,durandal,grunt-contrib-watch,Node.js,Requirejs,Durandal,Grunt Contrib Watch,为了提高我的一般编码技能。。。学习新的东西。 我已经开始尝试建立一个只有前端的解决方案,包括 杜兰达尔 茉莉花-[通过npm添加] Grunt Watch在代码文件更改时监视并运行我的测试-[通过npm添加] 请随意纠正我,因为这都是基于我在过去两天的实验。这些对我来说都是新鲜事。我的目标是拥有与因果报应相似的东西 现在我知道Durandal项目(附带一个定制的规范运行程序,如github解决方案中所示) 我的设置: grunfile.js module.exports = functi

为了提高我的一般编码技能。。。学习新的东西。 我已经开始尝试建立一个只有前端的解决方案,包括

  • 杜兰达尔
  • 茉莉花-[通过npm添加]
  • Grunt Watch在代码文件更改时监视并运行我的测试-[通过npm添加]
  • 请随意纠正我,因为这都是基于我在过去两天的实验。这些对我来说都是新鲜事。我的目标是拥有与因果报应相似的东西

    现在我知道Durandal项目(附带一个定制的规范运行程序,如github解决方案中所示)

    我的设置:

    grunfile.js

        module.exports = function(grunt) {
        var appPath = 'App/viewmodels/*.js';
        var testPath = 'Tests/**/*.js';
        grunt.initConfig({
            jasmine:    {
                pivotal: {
                    src: appPath,
                    options: {
                        specs: testPath,
                        template: require('grunt-template-jasmine-requirejs'),
                        templateOptions: {
                          requireConfigFile: 'SpecRunner.js'
                        }
                    }
                }
            },
            jshint: {
                all: [testPath, appPath],
                options: {
                    curly: true
                }
            },
            watch: {
                files: [testPath, appPath], 
                tasks: ['jshint','jasmine']
            }   
        });
    
        grunt.loadNpmTasks('grunt-contrib-jasmine');
        grunt.loadNpmTasks('grunt-contrib-jshint');
        grunt.loadNpmTasks('grunt-contrib-watch');
    
        grunt.registerTask('default', ['jshint','jasmine']);    
    };
    
    require.config({
      paths: {
        jquery: 'Scripts/jquery-1.9.1',
        knockout: 'Scripts/knockout-2.3.0'
      },
      shim: {
        knockout: {
          exports: "ko"
        }
      }
    });
    
    SpecRunner.js

        module.exports = function(grunt) {
        var appPath = 'App/viewmodels/*.js';
        var testPath = 'Tests/**/*.js';
        grunt.initConfig({
            jasmine:    {
                pivotal: {
                    src: appPath,
                    options: {
                        specs: testPath,
                        template: require('grunt-template-jasmine-requirejs'),
                        templateOptions: {
                          requireConfigFile: 'SpecRunner.js'
                        }
                    }
                }
            },
            jshint: {
                all: [testPath, appPath],
                options: {
                    curly: true
                }
            },
            watch: {
                files: [testPath, appPath], 
                tasks: ['jshint','jasmine']
            }   
        });
    
        grunt.loadNpmTasks('grunt-contrib-jasmine');
        grunt.loadNpmTasks('grunt-contrib-jshint');
        grunt.loadNpmTasks('grunt-contrib-watch');
    
        grunt.registerTask('default', ['jshint','jasmine']);    
    };
    
    require.config({
      paths: {
        jquery: 'Scripts/jquery-1.9.1',
        knockout: 'Scripts/knockout-2.3.0'
      },
      shim: {
        knockout: {
          exports: "ko"
        }
      }
    });
    
    当我运行grunt时,我得到一个非法路径或脚本错误:['plugins/http'] (我已在截图中整理出ko问题)

    问题:


    我将如何设置GrunFile以要求任何依赖项。我对require很陌生,我不知道如何配置它,使我的测试知道在哪里可以找到第三方库和其他自定义js文件,因此,

    SpecRunner
    require.config
    缺少Durandal特定的路径信息。如果将
    baseUrl
    设置为“App”,则下面的路径与HTML示例或StartKit布局匹配。如果您的布局不同,您必须相应地进行调整

    requirejs.config({
        paths: {
            'text': '../lib/require/text',
            'durandal':'../lib/durandal/js',
            'plugins' : '../lib/durandal/js/plugins',
            'transitions' : '../lib/durandal/js/transitions',
            'knockout': '../lib/knockout/knockout-2.3.0',
            'bootstrap': '../lib/bootstrap/js/bootstrap',
            'jquery': '../lib/jquery/jquery-1.9.1'
        }
    });