如何在Angular 4中测试特定的spec.ts文件?

时间:2018-01-18 07:14:56

标签: angular unit-testing karma-runner karma-jasmine

我是Angular的新手。我在我当前的项目中使用Angular 4.我正在学习使用angular进行单元测试,只是想知道我是否可以单独测试一个特定的spec.ts文件。

感谢任何帮助。

由于

3 个答案:

答案 0 :(得分:0)

使用describe f作为fdescribe的前缀,例如BindingContext="{x:Reference viewmodel}

答案 1 :(得分:-1)

使用System.Security.Cryptography.SHA256 sha = System.Security.Cryptography.SHA256.Create(); byte[] hash = sha.ComputeHash(Encoding.UTF8.GetBytes("<wsse:BinarySecurityToken xmlns=\"\" xmlns:wsse=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\" ValueType=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3\">MIIF...2A8=</wsse:BinarySecurityToken>")); string digestValue = Convert.ToBase64String(hash); 代替select ceiling(price) ------------------------------------------------------------------------- | test following numbers as inputted price value | Is my desired Output | | INPUT | OUTPUT | ------------------------------------------------------------------------- | 879999.51357924604783137 | 880000 | | 879999.50720242608036391 | 880000 | | 879999.47819604919865821 | 880000 | | 879999.49455676516329704 | 880000 | | 880000.5 | 880000 | ------------------------------------------------------------------------- ,它只会运行此fdescribe块内的测试。 IntelliJ / Webstorm还允许您从上下文菜单中测试单个文件

答案 2 :(得分:-1)

首先将组件转到组件的spec.ts文件中。 然后将f放在itdescribe的前面,这样就可以得到fdescribefit

然后转到控制台或终端,然后执行ng test

上述命令将仅执行fdescribefit测试用例,其他测试用例将被忽略。