我有一个带有Rails后端的单页Angular应用程序.我在我的index.html文件中使用了一个标签,但是当我使用Karma运行我的前端单元测试时,我得到了这个:
$location in HTML5 mode requires a <base> tag to be present
Run Code Online (Sandbox Code Playgroud)
我在我的主.js文件中这样做:
angular.module('my.module').config( function($locationProvider, $routeProvider) {
$locationProvider.html5Mode( true );
}
Run Code Online (Sandbox Code Playgroud)
那么,有没有什么方法可以<base>在业力实际呈现的页面中注入一个元素?或者,告诉Angular/Karma在运行单元测试时忽略此错误?
这个Google Groups线程和这个GitHub问题都描述了这个问题,但在这两种情况下解决方案都是简单地提升Angular的版本.我已经做到了,我甚至可以看到angular-mocks.js默认baseHref设置的行...
这是有问题的规范:
describe 'amnResource', ->
$compile = null
$rootScope = null
beforeEach ->
module 'ngMock'
module 'amn'
module 'directive.template.cache'
inject([ '$compile', '$rootScope', ($c, $r) ->
$compile = $c
$rootScope = $r
])
it 'compiles to an article', ->
console.log $rootScope
console.log $rootScope.foo
$rootScope.foo =
title: …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Jasmine规范文件对Angular服务进行单元测试.这需要加载模块.这是一个简单的规范,旨在简单地加载Angular模块:
describe('Submission services', function () {
it('Finds angular', function () {
module('submissionServices');
});
});
Run Code Online (Sandbox Code Playgroud)
当我运行Jasmine时,会导致以下错误
Running Jasmine specs...
FAIL: 1 test, 1 failure, 0.004 secs.
Submission services Finds angular. (/Users/XXX/Projects/globe_town/spec/javascripts/SubmissionsSpec.js:3)
ReferenceError: Can't find variable: module
Test ordering seed: --seed 1826
rake aborted!
Jasmine::Headless::TestFailure
Run Code Online (Sandbox Code Playgroud)
jasmine.yml文件包含
src_files:
- public/javascripts/jquery.js
- spec/javascripts/lib/angular/angular.js
- spec/javascripts/lib/angular/angular-resource.js
- app/assets/javascripts/services/submissions.js
stylesheets:
- stylesheets/**/*.css
helpers:
- helpers/**/*.js
spec_files:
- '**/*[sS]pec.js'
src_dir:
spec_dir: spec/javascripts
Run Code Online (Sandbox Code Playgroud)
该软件的版本是:
我需要做些什么才能让Jasmine找到Angular?
我一直在尝试使用jshint grunt模块来验证我的代码,但我总是得到以下错误:
Running "jshint" task
[D] Task source: C:\Coursera\03. Intro Angular JS\conFusion\node_modules\grunt-contrib-jshint\tasks\jshint.js
Running "jshint:all" (jshint) task
[D] Task source: C:\Coursera\03. Intro Angular JS\conFusion\node_modules\grunt-contrib-jshint\tasks\jshint.js
Verifying property jshint.all exists in config...OK
Files: Gruntfile.js, app/scripts/app.js
Options: force=false, reporterOutput=null, jshintrc=".jshintrc", reporter={}
Warning: Path must be a string. Received { toString: [Function], reporter: [Function] } Use --force to continue.
Run Code Online (Sandbox Code Playgroud)
问题是,即使使用--verbose和-debug,它也没有显示任何可以处理错误的内容,只是"路径必须是一个字符串",我用JSLint验证了文件(使用括号)并且它工作得很好,网站也行得很好.
到目前为止我做了什么.
我有一个基于Thelia和Composer 的非常简单的 Dockerfile 。我想要它做的尽可能多的设置成为可能,所以为此,我安装composer在PATH容器内,然后尝试运行composer install。但是,此时,容器中似乎还不存在我的本地/挂载文件(请参阅RUN echo pwd: ...下面的输出)。
构建失败并显示以下错误消息:
Composer 在 /var/www/html 中找不到 composer.json 文件
要初始化项目,请按照https://getcomposer.org/ “入门”部分中的说明创建 composer.json 文件
错误:服务“web”无法构建:命令“/bin/sh -c composer install”返回非零代码:1
请注意,在没有RUN composer install指令的情况下构建然后运行是docker-compose exec web composer install有效的。
docker-compose.yml 中声明的 mount 是否在镜像完全构建后生效?我是否需要明确地显示COPY我的本地文件,以便它们在构建过程中可见?
FROM php:5.6-apache
COPY docker-php-pecl-install /usr/local/bin/
RUN apt-get update && apt-get install -y \
libfreetype6-dev \
libjpeg62-turbo-dev \
libmcrypt-dev \
libpng12-dev \
libicu-dev \
git \
zip …Run Code Online (Sandbox Code Playgroud) 好吧,所以我得到jQuery Validate对于(不)验证时的观点是blur:
在字段被标记为无效之前,验证是懒惰的:在第一次提交表单之前,用户可以在不显示烦人消息的情况下对字段进行制表 - 在有机会实际输入正确值之前,它们不会被窃听
有没有办法覆盖这种行为?我希望每当它失去焦点时都要验证每个字段,而不仅仅是在出现错误之后.
我正在尝试为beanstalkd-cli. 图像构建成功,但是当我运行时docker run -it myimage,它失败了:
/usr/local/bin/beanstalkd-cli: line 1: ELF: not found
/usr/local/bin/beanstalkd-cli: line 2: syntax error: unexpected "("
Run Code Online (Sandbox Code Playgroud)
这是否意味着构建不好?或者我需要调整ENTRYPOINT和/或CMD?
这是我的 Dockerfile:
FROM alpine:3.5
LABEL maintainer="Coby Tamayo <ctamayo@sitecrafting.com"
# Install openssl, beanstalkd-cli
RUN apk add --update openssl && \
wget https://github.com/schickling/beanstalkd-cli/releases/download/0.3.0/beanstalkd-cli-linux.tar.gz && \
tar -xvzf beanstalkd-cli-linux.tar.gz && \
chmod +x beanstalkd-cli && \
mv beanstalkd-cli /usr/local/bin/beanstalkd-cli && \
rm beanstalkd-cli-linux.tar.gz
ENTRYPOINT ["/bin/sh"]
CMD ["/usr/local/bin/beanstalkd-cli"]
Run Code Online (Sandbox Code Playgroud)
当我完全删除ENTRYPOINT和 时CMD,运行容器会将我放到一个 shell …
在这个测试中,我只是试图断言该end属性是在被测组件上设置的 ( DateRangeEditor)。该组件假定this.$refs.datepicker是一个实例HotelDatepicker并调用它的setCheckOut和setCheckIn方法(如果有更好的方法来做到这一点,请告诉我!)。
该组件在浏览器中正常加载时工作,但我的测试setEndDate失败并显示“TypeError: this.$refs.datepicker.setCheckIn is not a function”。
我是否误解了该stubs选项应该做什么设置?我认为像这样的场景,调用代码只需要调用存根函数而不需要特定结果,正是存根的用途。我只是用错了吗?
这是我的测试:
import { mount, shallow } from 'vue-test-utils'
import DateRangeEditor from '../../assets/src/components/DateRangeEditor.vue'
describe('DateRangeEditor', () => {
describe('@checkOutChanged', () => {
it('sets a new end date', () => {
const wrapper = shallow(DateRangeEditor, {
stubs: ['datepicker']
})
// simulate user changing the end date
const date = new Date(2017, 11, 1)
wrapper.vm.$refs.datepicker.$emit('checkOutChanged', date)
expect(wrapper.vm.end).to.equal(date)
}) …Run Code Online (Sandbox Code Playgroud) 我正在浏览Clojure的源代码中的core.clj,并遇到了的定义defn。它定义的函数有几个参数,第一个是&formand &env:
(def
defn (fn defn [&form &env name & fdecl]
;; ...
))
Run Code Online (Sandbox Code Playgroud)
这些名称是否以它们开头而具有特殊含义&?
我知道rest args和速记匿名函数var %&,但是这似乎都不是。
我没有在Reader参考中找到有关此语法的任何内容,该参考没有&明确提及:
符号以非数字字符开头,可以包含字母数字字符以及*,+,!,-,_,',?,<,>和=(其他字符最终可能允许)。
阅读Clojure角色似乎也没有提到这一点。在其文档字符串中resolve包含一个&envarg,但不再赘述。
I have a map like {:a "A" :b "B"} and want to convert its keys to strings, e.g. {"a" "A" "b" "B"}.
I have this function, which works:
(defn keyword-keys->strs [m]
(zipmap
(map name (keys m))
(map second (vec m))))
Run Code Online (Sandbox Code Playgroud)
But is there a more idiomatic or purpose-built way to do it?
Thanks!