angular / angular/angular-cli

SchematicTestRunner.callRule does not use the logger by default

Open
#12,087 0 comments 0 reactions 0 assignees View on GitHub
area: @angular-devkit/schematics effort1: easy (hours) type: bug/fix
Dominant language
TypeScript
Stars
27k
Forks
11.8k
Avg merge
14h 23m
Merged PRs (30d)
162

Description

_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_

Contributor guide

Open the contributing guide

Research direction

Start at SchematicTestRunner.callRule and trace how its logger is provided to the rule context. Review the unit tests for rules and reproduce the shown example, then verify that the runner's logger receives “Hello world!” by default.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
testing
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.