angular / angular/angular

APP_INITIALIZER contract not honoured with TestBed

未关闭
#24,218 17 条评论 23 个 reaction 已指派 0 人 在 GitHub 查看
area: testing freq1: low P3 type: bug/fix
主要语言
TypeScript
星标
101k
派生
27.5k
平均合并
1 天 19 小时
30 天内合并 PR
288

描述

## I'm submitting a...



[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
[ ] Other... Please describe:

## Current behavior

When importing a Module providing a promise-based APP_INITIALIZER into a TestBed, the tests are executed before the promise is fully resolved.

There was an issue for this very problem (#16204) but the reporter closed because he found a workaround.

## Expected behavior

The promise of an APP_INITIALIZER should be fully resolved, exactly as when running the application that uses this module normally.

## Minimal reproduction of the problem with instructions

Hadn't had the time, but I expect that it should be simple to know if is already implemented or not to behave like expected. If yes, I will produce a repro.

## What is the motivation / use case for changing the behavior?

Same contract with tests or real app.

## Environment



Angular version: 6.0.7

贡献指南

打开贡献指南

调研方向

首先检查 TestBed 和 APP_INITIALIZER 入口点,并使用一个最小测试复现报告的基于 promise 的初始化行为。完成标准是:测试在执行前等待 APP_INITIALIZER promise resolve,这与应用程序的正常契约一致。

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

评估

技术栈
angular, typescript
领域
testing
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
需要澄清
新手友好度
25/100

把新 issue 发到你的邮箱

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