Test Angular 9 (TypeScript) with Mocha and JavaScript Syntax

st_stefanov

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.

Philipp Meissner

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.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Cannot test typescript with mocha syntax error

Accessing test title in Mocha with TypeScript

JavaScript, mocha test for random numbers

Angular 7 - Typescript syntax

Mocha Chai test case for angular configuration file

Mocha/angular unit test never runs 'then' function

Retrieve the current test's name within a Mocha test using Typescript

JavaScript / Mocha - How to test if function call was awaited

JavaScript test (mocha) with 'import' js file

Unit test issue with Mocha and Sinon using javascript

http post for auth in javascript using mocha test

Matching JavaScript files, but excluding mocha test files

Javascript Mocha test TypeError: x is not a constructor

<> syntax in Typescript Angular2

Typescript import syntax with Angular / Rxjs

Angular2 typescript syntax

Finding ResizeObserver with Typescript in Angular 9

Mocha can't find my test files when using TypeScript

How to run a single mocha test written in typescript in WebStorm 2016.1

Mocha test not working with Typescript namespace and triple slash import

How to increase the mocha timeout per suite in a typescript test

Javascript test() method syntax error?

Can not test something with mocha when I have angular (1.6) as a dependency

Mixing typescript and javascript modules when running Mocha tests

How to test pure JavaScript module with mocha.js

How to debug with visual studio code a mocha test in javascript?

Run different modules in a test_file.js in javascript in mocha

Syntax of member properties and constructors in angular 2 typescript

Typescript angular 2 ng-book syntax