angular / angular/angular-cli

SchematicTestRunner.callRule does not use the logger by default

未关闭
#12,087 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
area: @angular-devkit/schematics effort1: easy (hours) type: bug/fix
主要语言
TypeScript
星标
27k
派生
11.8k
平均合并
14 小时 23 分钟
30 天内合并 PR
162

描述

_From @FrozenPandaz on June 6, 2018 3:12_

### Bug Report or Feature Request (mark with an `x`)
```
- [x] bug report -> please search issues before submitting
- [ ] feature request
```

### Area
```
- [x] devkit
- [ ] schematics
```

### Versions

Ubuntu

### Repro steps

```ts

const schematicRunner = new SchematicTestRunner(
collectionName,
pathToCollectionJson
);
const spy = spyOn(schematicRunner.logger, 'info');
schematicRunner
.callRule((host: Tree, context: SchematicContext) => {
context.logger.info('Hello world!');
, Tree.empty())
.subscribe(result => {
expect(spy).toHaveBeenCalledWith('Hello world!');
});
```
### The log given by the failure

Expected spy to have been called 'Hello world!' but was not called.

### Desired functionality

The SchematicTestRunner logger should be used by default and the test should pass

### Mention any other details that might be useful

Any unit tests which test rules

_Copied from original issue: angular/devkit#1016_

贡献指南

打开贡献指南

调研方向

从 SchematicTestRunner.callRule 开始,跟踪其 logger 是如何提供给规则上下文的。查看规则的单元测试并复现所示示例,然后验证 runner 的 logger 默认会接收到 “Hello world!”。

由索引模型根据 Issue 内容生成。

评估

技术栈
typescript
领域
testing
Issue 类型
缺陷
难度
2/5
预计耗时
1-3 小时
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。