angular / angular/components

A "Testing with Material Components" guide to demonstrate including core theme in test suite

未关闭
#4,056 30 条评论 41 个 reaction 已指派 0 人 在 GitHub 查看
area: material.angular.io docs feature help wanted P3
主要语言
TypeScript
星标
25k
派生
6.8k
平均合并
1 天 8 小时
30 天内合并 PR
91

描述

#### Bug, feature request, or proposal:
Bug or missing docs

#### What is the expected behavior?
Tests shouldn't log warnings after following the Getting Started guide on a fresh cli generated app.

#### Current behavior / steps to reproduce

1. Fresh cli app
2. Follow the getting started guide
3. Add an `md-card` component to AppComponent
4. Run unit tests
5. Resulting warning:

```
WARN: 'Could not find Angular Material core theme. Most Material components may not work as expected. For more info refer to the theming guide: https://material.angular.io/guide/theming'
Chrome 57.0.2987 (Mac OS X 10.12.4): Executed 0 of 3 SUCCESS (0 secs / 0 secs)
Chrome 57.0.2987 (Mac OS X 10.12.4): Executed 3 of 3 SUCCESS (0.226 secs / 0.199 secs)
```

#### Is there anything else we should know?
Modifying `karma.conf.js` to include a theme silenced the warning. This approach was borrowed from [Material's karma config](https://github.com/angular/material2/blob/master/test/karma.conf.js#L35-L36):

```
files: [
{ pattern: './src/test.ts', watched: false },
{ pattern: './node_modules/@angular/material/prebuilt-themes/indigo-pink.css' }
],
```

贡献指南

打开贡献指南

调研方向

阅读 Getting Started 指南和现有的 karma.conf.js,然后将测试设置与所引用的 Material karma 配置以及新建 CLI 应用的步骤进行比较。添加 md-card 后运行单元测试,并确认 core-theme 警告已消失,同时在指南中记录所需的测试设置。

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

评估

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

把新 issue 发到你的邮箱

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