简体   繁体   English

使用 Mocha 和 JavaScript 语法测试 Angular 9 (TypeScript)

[英]Test Angular 9 (TypeScript) with Mocha and JavaScript Syntax

We recently migrated to Angular 9 (Type Script) from Angular.js and would like to continue writing our tests in Mocha, but keep the JavaScript syntax (not writing tests in TypeScript Mocha). We recently migrated to Angular 9 (Type Script) from Angular.js and would like to continue writing our tests in Mocha, but keep the JavaScript syntax (not writing tests in TypeScript Mocha).

Is that possible to write JavaScript test for Type Script code (I know that JavaScript syntax is possible to write, this is not what I am asking) - the question is - is it possible to test the actual TypeScript components of Angular? Is that possible to write JavaScript test for Type Script code (I know that JavaScript syntax is possible to write, this is not what I am asking) - the question is - is it possible to test the actual TypeScript components of Angular?

Any guides/article will be appreciated.任何指南/文章将不胜感激。

Thanks.谢谢。

The required behavior should just work as you want it.所需的行为应该按照您的意愿工作。

TypeScript is basically just a (visual) layer on top of JavaScript. TypeScript 基本上只是 JavaScript 之上的(视觉)层。 Either create a .spec.ts files and write default JavaScript code, or create .spec.js files and write JavaScript.要么创建.spec.ts文件并编写默认 JavaScript 代码,要么创建.spec.js文件并编写 JavaScript。 Either way, it should "just work".无论哪种方式,它都应该“正常工作”。 If anything you need to check if you have settings defined that mocha will only load certain extensions for your tests.如果您需要检查是否定义了设置,则 mocha 只会为您的测试加载某些扩展。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM