简体   繁体   中英

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).

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. Either create a .spec.ts files and write default JavaScript code, or create .spec.js files and write 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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