小编dma*_*alu的帖子

在测试角度指令时,即使用ng-html2js,也可以使用Karma'意外请求'

在最后一天尝试完成这项工作之后,我发现我已经绕回到我在开始时遇到的同样错误:

错误:意外请求:GET test-directive.html

我正在使用Karma和Jasmine来测试Angular中的指令.我在StackOverflow上查看了类似的问题,但发现在其他示例中尝试过的所有内容都无济于事.

代码结构

Test-App
-src
--bower
--lib
--js
--modules
--- testDir
---- test.js
---- test-directive.html
---- test
----- test.spec .js文件
-test
--config
--- karma.conf.js
--e2e

Karma Config

'use strict';
module.exports = function(config){
    config.set({
    basePath: '../../',
    frameworks: ['jasmine'],
    files: [
        // Angular
        'src/bower/angular/angular.js',
        // Mocks
        'src/bower/angular-mocks/angular-mocks.js',
        // Libraries
        'src/lib/**/*.js',
        // App
        'src/js/*.js',
        'src/modules/*/*.js',
        // Tests
        'src/modules/**/test/*spec.js',
        // Templates
        'src/modules/**/*.html'
    ],
    autoWatch: false,
    singleRun: true,
    reporters: ['progress'],
    browsers: ['PhantomJS'],

    preprocessors: {
        'src/modules/**/*.html': 'ng-html2js'
    },
    ngHtml2JsPreprocessor: {
        moduleName: 'dir-templates'
    },
    plugins: …
Run Code Online (Sandbox Code Playgroud)

unit-testing angularjs angularjs-directive karma-runner

25
推荐指数
1
解决办法
1万
查看次数

Gruntjs - 以特定顺序运行多个阻止任务(Mongo和Node.js)

我最近对Gruntjs表示了爱意,并且很高兴能抓住每一个机会让我的发展生活变得更加轻松.我目前正在编译我的SASS文件,运行手表,并使用nodemon来保持我的节点服务器更新,因为我在应用程序上工作.

所以这就是我早上开车疯狂的地方.我想在Node应用程序运行之前启动MongoDB.在Node应用程序的设置中,我检查数据库中的任何值,如果它是空的,则将充满信息的测试文件推送到表中.

我目前尝试使用grunt-concurrentgrunt-shell-spawn来运行必要的mongo和node命令.

grunt.initConfig({
  shell: {
    mongo: {
      command: 'mongo'
    },
    node: {
      command: 'node app.js'
    }
  },
  concurrent: {
    dev: {
      tasks: ['shell:mongo','shell:node'],
      options: { logConcurrentOutput: true }
    }
  }
});
grunt.loadNpmTasks('grunt-concurrent');
grunt.loadNpmTasks('grunt-shell-spawn');
Run Code Online (Sandbox Code Playgroud)

有没有办法确保mongo命令在运行节点任务之前达到"阻塞"状态?我猜这可以通过在setTimeout函数上运行节点任务异步来完成,但我不想一直等待看到开发过程中的更改生效.目前我一直在为数据库打开一个单独的shell选项卡,并且非常希望将它集成到Grunt中以将所有内容保存在一个地方.

我不确定它在大范围内的重要性,但是任何使用Node.js和MongoDB的人都会发现它非常有用.

谢谢

shell terminal mongodb node.js gruntjs

5
推荐指数
1
解决办法
645
查看次数