小编Man*_*uel的帖子

如何使用`entryComponents`对组件进行浅层测试?

例如,假设您有以下组件:

import { Another } from "./Another";
@Component({
    entryComponents: [
        Another
    ]
})
export class App {}
Run Code Online (Sandbox Code Playgroud)

即使在使用时NO_ERRORS_SCHEMA我仍然必须包含Another作为测试声明的一部分:

import { ComponentFixture, TestBed } from "@angular/core/testing";
import { NO_ERRORS_SCHEMA } from '@angular/core';
import { App } from "./App";
import { Another } from "./Another";

describe("App", () => {
  let comp: App;
  let fixture: ComponentFixture<App>;

  beforeEach(() => {
    TestBed.configureTestingModule({
      declarations: [ App, Another ],
      schemas: [ NO_ERRORS_SCHEMA ]
    });
    fixture = TestBed.createComponent(App);
    comp = fixture.componentInstance;
  });

  it("can load …
Run Code Online (Sandbox Code Playgroud)

angular

13
推荐指数
1
解决办法
6305
查看次数

无法安装ZenTest 4.8.4

当我尝试安装ZenTest时:

gem install ZenTest
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

[C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/specifications/ZenTest-4.8.4.gemspec]中的gemspec无效:格式错误的要求["<2.1,> = 1.8"]

我试图清理宝石并删除ZenTest无济于事.

怎么了?

gem ruby-on-rails zentest

10
推荐指数
1
解决办法
5039
查看次数

如何使用VSCode扩展添加上下文菜单?

你如何添加上下文菜单?(在资源管理器和/或编辑器中)

我尝试了以下不起作用:

{
    "command": "extension.sayHello",
    "title": "Say Hello",
    "context": {
        "where": "explorer/context",
        "when": "json"
    }
}
Run Code Online (Sandbox Code Playgroud)

这是基于:

https://github.com/Microsoft/vscode/issues/3192

https://github.com/Microsoft/vscode/pull/7704

visual-studio-code vscode-extensions

10
推荐指数
1
解决办法
8007
查看次数

Angular的NO_ERRORS_SCHEMA存在问题?

在测试具有子组件的组件时,您有以下几种选择:

  1. 导入设置组件和子组件的模块.问题是你实例化真正的子组件及其依赖项.
  2. 模拟子组件.这可能很繁琐,具体取决于它有多少个子组件.
  3. 使用NO_ERRORS_SCHEMA和忽略子组件.

鉴于大多数时候你只关心当前的组件,为什么NO_ERRORS_SCHEMA在测试教程,博客文章等中没有给予更多关注?

我知道它被标记为实验性的,但我并不为此感到困扰

  1. 它与Angular的其余部分一起发货,并且
  2. 考虑到它的历史和即将发布的周期,整个Angular堆栈几乎是实验性的.

那么有问题NO_ERRORS_SCHEMA吗?或者只是偶然的事情,它不会被提升更多?

unit-testing angular

10
推荐指数
1
解决办法
3110
查看次数

How to add an import to the file with Babel

Say you have a file with:

AddReactImport();
Run Code Online (Sandbox Code Playgroud)

And the plugin:

export default function ({types: t }) {
  return {
    visitor: {
      CallExpression(p) {
        if (p.node.callee.name === "AddReactImport") {
          // add import if it's not there
        }
      }
    }
  };
}
Run Code Online (Sandbox Code Playgroud)

How do you add import React from 'react'; at the top of the file/tree if it's not there already.

I think more important than the answer is how you find out how to do it. Please tell me because I'm …

babeljs

8
推荐指数
2
解决办法
2636
查看次数

如何在使用分离器后重置网格行高?

使用以下XAML,取消选中该复选框时会隐藏底行.一切顺利,直到你用网格探测器调整大小.然后选中/取消选中该复选框不会执行任何操作.鉴于转换器将高度设置为0,我希望该行隐藏.这是怎么回事?移动分离器后如何重置高度?

<Grid>
    <Grid.Resources>
        <m:CheckedToLengthConverter x:Key="checkedToLengthConverter" />
    </Grid.Resources>
    <Grid.RowDefinitions>
        <RowDefinition Height="3*" />
        <RowDefinition Height="{Binding Mode=OneWay, ElementName=ShowBottomCheckBox, Path=IsChecked, Converter={StaticResource checkedToLengthConverter}, ConverterParameter=2}" />
    </Grid.RowDefinitions>
    <Border Background="Blue" />
    <CheckBox Name="ShowBottomCheckBox" IsChecked="True" />
    <GridSplitter HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Height="5" />
    <Border Background="Red" Grid.Row="1" />
</Grid>
Run Code Online (Sandbox Code Playgroud)

转换器:

public class CheckedToLengthConverter: IValueConverter
{
    public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
        if ((bool)value)
            return new GridLength(int.Parse(parameter.ToString()), GridUnitType.Star);

        return new GridLength(0, GridUnitType.Pixel);
    }

    public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
        throw new NotImplementedException(); …
Run Code Online (Sandbox Code Playgroud)

wpf

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

Consolas空间长度比Notepad ++中的预期短

我在Notepad ++中为Haml文件创建了一个用户定义的语言.所有Consolas/10都是全面的.除了空格与字母长度不同外,样式应用得很好.可能有什么不对?

用户定义语言的Consolas

更新:

如果我将Ruby语言字体设置为Consolas/10,则空格的长度与字母的长度相同.

来自预定义语言的Consolas

notepad++

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

将Add方法添加到ActiveRecord数组

我有型号和产品.如果我使用category.products << new_product该项添加到数组中,则记录将保存到数据库中.我尝试将以下"add"方法添加到数组类中,虽然它确实将new_product添加到数组中,但它不会将其保存到数据库中.这是为什么?

class Array
  def add(item)
    self << item
  end
end
Run Code Online (Sandbox Code Playgroud)

更新:

collection_proxy.rb具有以下方法:

def <<(*records)
  proxy_association.concat(records) && self
end
alias_method :push, :<<
Run Code Online (Sandbox Code Playgroud)

所以以下扩展工作:

class ActiveRecord::Relation
  def add(*records)
    proxy_association.concat(records) && self
  end
end
Run Code Online (Sandbox Code Playgroud)

解:

为CollectionProxy添加别名:

class ActiveRecord::Associations::CollectionProxy
  alias_method :add, :<<
end
Run Code Online (Sandbox Code Playgroud)

ruby activerecord ruby-on-rails

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

Heroku FATAL:不允许角色登录/数据库已取消配置

我正在 Heroku 上测试一个应用程序,突然开发数据库离线了。postgres.heroku.com 在数据库上有以下信息:

\n\n
Statistics\nPlan    Dev\nStatus  \nData Size   0 B\nTables  7\nPG Version  ?\nCreated     February 27, 2013 19:38\n
Run Code Online (Sandbox Code Playgroud)\n\n

日志说FATAL: role "-removed-" is not permitted to log in

\n\n

heroku 文档有错误,但它并没有真正帮助:

\n\n
FATAL: role \xe2\x80\x9crole-name\xe2\x80\x9d\xe2\x80\xa6\n\nFATAL: role "u8akd9ajka" is not permitted to log in (PG::Error)\n\nThis occurs when you have de-provisioned a starter tier database but are still trying to connect to it. To resolve:\n\n    If required, provision a new database via heroku addons:add heroku-postgresql\n    Use heroku pg:promote HEROKU_POSTGRESQL_<new-database-color> to …
Run Code Online (Sandbox Code Playgroud)

heroku

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

未定义的方法it_behaves_like/it_should_behave_like/include_examples

我正在为it_behaves_like,it_should_behave_like和include_examples获取未定义的方法.

测试是针对规格/功能的.我将文件包含在shared_examples/shared_examples_for中.

这是怎么回事?

rspec ruby-on-rails

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