我似乎无法在iOS上进行{N}单元测试......
1)需要带有NSAllowsArbitraryLoads的http。我宁愿不启用此功能,是否有一个例外,允许它只是为业力启用。
2)错误:找不到模块' chai'。计算路径' / Users / steve / Library / Developer / CoreSimulato R /设备/ 3607EE15-7B8D-46AE-9DE4-2526D5E91E1F /数据/容器/捆绑/应用/ EBBB37FA-F126-499C-9B C1-D39179A0F58E / MyApp.app /应用程序/ tns_modules /柴'
这是所有的测试
/// <reference path="../../typings/mocha/mocha.d.ts" />
import * as helpers from '../scripts/helpers';
import {assert} from 'chai'
describe('Hello World Sample Test:', function () {
it('Counter should be 42 on start.', function () {
assert.equal(42, 42);
});
});
所以TypeScript没有显示任何错误,chai绝对在我的node_modules中,获得了所有的intellisense良好。
但确实像错误一样,它似乎没有包含所有其他tns内容(以及我的其他插件)在该文件夹中?
有人有这个工作还是个bug?
答案 0 :(得分:1)
根据我的经验,似乎{N}自动将断言作为全局函数导入,基本上你不需要在测试中导入它。所以尝试删除:
import {assert} from 'chai'
并将其替换为
declare var assert: Chai.AssertStatic;
这样TypeScript就不会抱怨,然后测试也应该在执行时起作用。
我在这里进行了mocha / chai测试https://github.com/PeterStaev/nativescript-azure-mobile-apps/tree/master/sample,因此您可以查看更多详细信息。