在我们的rails
和angularjs
之一中,最近将angularjs从1.2.9升级到1.3.0,用纱取代了凉亭,并从节点0.8.28升级到8.11.1。一切都可以在用户界面中正常运行。
我通过严格依赖使用ng-strict-di
指令并显式注释所有依赖项来修复了应用程序中缺少的模块错误。
我们使用capybara和poltergiest
进行功能测试,我用selenium
替换了poltergiest,所有茉莉花规格都运行良好。
我们使用grunt作为任务运行程序,所有资产都被编译到根级别的public
文件夹中,当capybara启动服务器时,它将在指定端口上的public
文件夹中运行该应用程序。
我不了解或找不到水豚如何从public
文件夹中的已编译应用程序启动该应用程序。
出于测试目的,我让功能规格在chrome中运行,但得到了臭名昭著的错误,
[$injector:nomod] Module 'app' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
我无法弄清楚为什么在运行实际应用程序时却没有出现该错误,而只是在功能规格方面。
这是我的Gruntfile.js
'use strict';
var proxySnippet = require('grunt-connect-proxy/lib/utils').proxyRequest;
var serveStatic = require('serve-static');
module.exports = function (grunt) {
// load all grunt tasks
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
// configurable paths
var yeomanConfig = {
app: 'app',
dist: '../public'
};
try {
yeomanConfig.app = require('./package.json').appPath || yeomanConfig.app;
} catch (e) {}
grunt.initConfig({
ngtemplates: {
app: {
options: {
base: 'app',
// concat: '<%= yeoman.dist %>/scripts/scripts.js'
concat: 'generated'
},
src: ['app/views/**/*.html'],
dest: '.tmp/template.js'
}
},
yeoman: yeomanConfig,
watch: {
all : {
options : { livereload: true },
files: [
'<%= yeoman.app %>/{,*/}*.html',
'{.tmp,<%= yeoman.app %>}/styles/{,*/}*.css',
'{.tmp,<%= yeoman.app %>}/scripts/{,*/}*.js',
'<%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
],
tasks: ['jshint']
}
},
connect: {
proxies: [{
context: '/api',
host: '127.0.0.1',
port: 5000,
https: false,
changeOrigin: false
}, {
context: '/public/api',
host: '127.0.0.1',
port: 5000,
https: false,
changeOrigin: false
}, {
context: '/print',
host: '127.0.0.1',
port: 5000,
https: false,
changeOrigin: false
}, {
context: '/users',
host: '127.0.0.1',
port: 5000,
https: false,
changeOrigin: false
}],
livereload: {
options: {
port: 9000,
// Change this to 'localhost' to restrict access to the server from outside.
hostname: '0.0.0.0',
middleware: function () {
return [
require('connect-livereload')(),
proxySnippet,
serveStatic('.tmp'),
serveStatic('test'),
serveStatic(yeomanConfig.app)
];
}
}
},
test: {
options: {
port: 9001,
middleware: function () {
return [
serveStatic('.tmp'),
serveStatic('test')
];
}
}
},
teste2e: {
options: {
port: 9002,
hostname: 'localhost',
middleware: function () {
return [
proxySnippet,
serveStatic('.tmp'),
serveStatic('test'),
serveStatic(yeomanConfig.app)
];
}
}
}
},
open: {
server: {
url: 'http://localhost:<%= connect.livereload.options.port %>'
}
},
clean: {
options: {
force: true
},
dist: ['.tmp', '<%= yeoman.dist %>/*'],
server: '.tmp'
},
jshint: {
options: {
jshintrc: '.jshintrc'
},
all: [
'Gruntfile.js',
'<%= yeoman.app %>/scripts/{,*/}*.js',
'<%= yeoman.app %>/modules/{,*/}*.js'
]
},
karma: {
unit: {
configFile: 'karma.conf.js',
singleRun: true
},
dev: {
configFile: 'karma.conf.js',
singleRun: false
},
e2e: {
configFile: 'karma-e2e.conf.js',
singleRun: true
}
},
coffee: {
dist: {
files: {
'.tmp/scripts/coffee.js': '<%= yeoman.app %>/scripts/*.coffee'
}
},
test: {
files: [{
expand: true,
cwd: '.tmp/spec',
src: '*.coffee',
dest: 'test/spec'
}]
}
},
compass: {
options: {
sassDir: '<%= yeoman.app %>/styles',
cssDir: '.tmp/styles',
imagesDir: '<%= yeoman.app %>/images',
javascriptsDir: '<%= yeoman.app %>/scripts',
fontsDir: '<%= yeoman.app %>/styles/fonts',
importPath: 'app/components',
relativeAssets: true
},
dist: {},
server: {
options: {
debugInfo: true
}
}
},
concat: {
dist: {
files: {
'<%= yeoman.dist %>/scripts/scripts.js': [
'.tmp/scripts/{,*/}*.js',
'<%= yeoman.app %>/scripts/{,*/}*.js'
]
}
}
},
useminPrepare: {
html: '<%= yeoman.app %>/index.html',
options: {
dest: '<%= yeoman.dist %>'
}
},
rev: {
files: {
src: ['<%= yeoman.dist %>/lib/components.js', '<%= yeoman.dist %>/lib/components-ie8.js', '<%= yeoman.dist %>/lib/components-ie.js', '<%= yeoman.dist %>/scripts/scripts.js', '<%= yeoman.dist %>/styles/main.css']
}
},
usemin: {
html: ['<%= yeoman.dist %>/{,*/}*.html'],
css: ['<%= yeoman.dist %>/styles/{,*/}*.css'],
options: {
dirs: ['<%= yeoman.dist %>']
}
},
imagemin: {
dist: {
files: [{
expand: true,
cwd: '<%= yeoman.app %>/images',
src: '{,*/}*.{png,jpg,jpeg}',
dest: '<%= yeoman.dist %>/images'
}]
}
},
cssmin: {
dist: {
files: {
'<%= yeoman.dist %>/styles/main.css': [
'.tmp/styles/{,*/}*.css',
'<%= yeoman.app %>/styles/{,*/}*.css'
]
}
}
},
htmlmin: {
dist: {
options: { },
files: [{
expand: true,
cwd: '<%= yeoman.app %>',
src: ['*.html', 'views/*.html'],
dest: '<%= yeoman.dist %>'
}]
}
},
ngmin: {
dist: {
files: [{
expand: true,
cwd: '<%= yeoman.dist %>/scripts',
src: '*.js',
dest: '<%= yeoman.dist %>/scripts'
}]
}
},
uglify: {
dist: {
files: {
'<%= yeoman.dist %>/scripts/scripts.js': ['<%= yeoman.dist %>/scripts/*.js']
}
}
},
copy: {
dist: {
files: [{
expand: true,
dot: true,
cwd: '<%= yeoman.app %>',
dest: '<%= yeoman.dist %>',
src: [
'*.{ico,txt}',
'.htaccess',
'fonts/**/*',
'scriptx/**/*',
'lib/**/*',
'images/{,*/}*.{gif,webp,svg}'
]
}]
}
}
});
grunt.registerTask('server', [
'clean:server',
'coffee:dist',
'compass:server',
'configureProxies',
'connect:livereload',
'open',
'watch'
]);
grunt.registerTask('test', [
'clean:server',
'coffee',
'compass',
'connect:test',
'karma:unit'
]);
grunt.registerTask('test-e2e', [
'clean:server',
'coffee',
'compass',
'configureProxies',
'connect:teste2e',
'karma:e2e'
]);
grunt.registerTask('deploy', [
'clean:dist',
'coffee',
'compass:dist',
'useminPrepare',
'imagemin',
'cssmin',
'htmlmin',
'ngtemplates',
'concat',
'ngmin',
'uglify',
'copy',
'rev',
'usemin'
]);
grunt.registerTask('build', [
'clean:dist',
'jshint',
'karma:unit',
'compass:dist',
'useminPrepare',
'imagemin',
'cssmin',
'htmlmin',
'ngtemplates',
'concat',
'ngmin',
'uglify',
'copy',
'rev',
'usemin'
]);
grunt.registerTask('default', ['build']);
};
这是我的功能规格,
require 'spec_helper'
require 'vcr'
require 'timecop'
Capybara.default_max_wait_time = 10
feature "Consignment creation and dispatch" do
include SpecHelpers
include Acceptance
scenario "Creating a Consignment", :js => true do
puts "Running with #{Capybara.current_driver}"
VCR.use_cassette('cassete file') do
end
end
end
让我知道是否需要更多信息。
答案 0 :(得分:0)
我终于知道发生了什么事,
我开始调试的方式是,我从jenkins的应用程序的UIImageView.image
文件夹中提取了已编译的资产,并用它在本地进行了测试,我发现它缺少某些软件包以及发生这种情况的原因是(我不确定如何),
在旧的设置中,我们将存储库中的components文件夹推送到了它的dist文件夹中,但是现在我要从public
下载所有内容,并且它不会生成package.json
文件夹在服务器上,但在本地文件夹上,因此缺少模块错误。