NativeScript / NativeScript/nativescript-cli
tns test fails with error "ReferenceError: Can't find variable: Zone"
未关闭
还没有人认领这个 Issue。
to-be-checked
unit testing
- 主要语言
- JavaScript
- 星标
- 1.1k
- 派生
- 204
- 平均合并
- 1 天 9 小时
- 30 天内合并 PR
- 8
描述
Tell us about the problem
Please, ensure your title is less than 63 characters long and starts with a capital
letter.
Which platform(s) does your issue occur on?
iOS, Android
Please provide the following version numbers that your issue occurs with:
-
CLI: (run
tns --versionto fetch it)
3.4.0 -
Cross-platform modules: (check the 'version' attribute in the
node_modules/tns-core-modules/package.jsonfile in your project)
3.3.0 -
Runtime(s): (look for the
"tns-android"and"tns-ios"properties in the
package.jsonfile of your project)
3.0.0
Please tell us how to recreate the issue in as much detail as possible.
- Build a service that requires injection of TranslateService (from ng-translate)
- Inject that service in beforeEach() of a test suite.
Is there code involved? If so, please share the minimal amount of code needed to recreate the problem.
error.service.test.ts
'use strict';
import {ErrorService} from '../services/error.service';
import {inject} from "@angular/core/testing";
declare let assert: Chai.AssertStatic;
describe("ErrorService tests", () => {
let service = null;
beforeEach((done) => {
inject([ErrorService], (injectService: ErrorService) => {
service = injectService;
done();
});
});
it("Service exists", (done) => {
assert.exists(service);
done();
});
});
error.service.ts
import { Injectable } from "@angular/core";
import { TranslateService } from "ng2-translate";
@Injectable()
export class ErrorService {
constructor(private i18n: TranslateService) {
}
}
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先,使用为 CLI、模块和运行时列出的版本,重现报告的 tns 测试失败。阅读 error.service.test.ts 和 error.service.ts,重点关注 beforeEach() 中的 Angular 测试注入。完成的标准是服务测试在 iOS 和 Android 上都能运行,且不会出现关于 Zone 的 ReferenceError。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- angular, javascript
- 领域
- cli, mobile, testing
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 需要澄清
- 新手友好度
- 25/100